/* Timeline modifications - allow text wrapping */
.css-1q5druj {
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    height: auto !important;
    min-height: auto !important;
}

.css-1qt3w04 .s1a0c8w6 {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-wrap: break-word;
    max-width: 100%;
    height: auto !important;
    max-height: none !important;
}

.css-v5li4m,
.s18eta8o {
    width: 100%;
    max-width: 100%;
    height: auto !important;
    overflow: visible !important;
}

.css-mq27um,
.css-kko757 {
    height: auto !important;
    min-height: auto !important;
}

/* ============================================
   CUSTOM FIELD ORDERING
   ============================================ */
/* Make the container use flexbox for ordering */
.css-1iz6ik5 {
    display: flex;
    flex-direction: column;
}

/* Set default high order for all field items */
.css-1bhgmbo {
    order: 999;
    width: 100%;
    display: flex;
}

.css-1tobuy {
    order: 999;
    width: 100%;
    display: flex;
}

/* ============================================
   SPECIFIC FIELD ORDERING
   Using class + div[id*="fieldname"] selectors
   ============================================ */
/* 0. Created By */
.css-1tobuy:has([id*="-createdBy"]) {
    order: 0;
}

/* 1. NombreApellido */
.css-1bhgmbo:has([id*="-nombreapellido"]) {
    order: 1;
}

/* 2. Telefono */
.css-1bhgmbo:has([id*="-telefono"]) {
    order: 2;
}

/* 3. Nota / Notas */
.css-1bhgmbo:has([id*="-nota"]) {
    order: 3;
}

.css-1tobuy:has([id*="-lastUpdateNota"]) {
    order: 3;
}

/* 4. Estado */
.css-1bhgmbo:has([id*="-estado"]) {
    order: 4;
}

/* 5. Medio */
.css-1bhgmbo:has([id*="-medio"]) {
    order: 5;
}

/* 6. Pesos */
.css-1bhgmbo:has([id*="-pesos"]) {
    order: 6;
}

/* 7. Dolares */
.css-1bhgmbo:has([id*="-dolares"]) {
    order: 7;
}

/* 8. WhatsApp */
.css-1tobuy:has([id*="-whatsapp"]) {
    order: 8;
}

/* 9. Updated At / Última actualización */
.css-1tobuy:has([id*="-updatedAt"]) {
    order: 9;
}

/* Ensure proper spacing */
.css-1iz6ik5 > * {
    margin-bottom: 0;
}

/* Force the entire area to be interactive for items in .css-1iz6ik5 */
.css-1iz6ik5 .css-1bhgmbo .css-qoso39 {
    width: 100% !important;
    background-color: #60a5fa !important;
    border: 1px solid #2563eb !important;
    border-radius: 4px;
    padding: 4px;
}

.css-1iz6ik5 .css-1bhgmbo .css-qoso39 * {
    width: 100% !important;
    pointer-events: auto !important;
}

/* Highlight sections that have the pencil button */
.css-1iz6ik5 .css-wx2q63:has(button.displayOnHover svg.tabler-icon-pencil) {
    background-color: #60a5fa !important;
    border-left: 3px solid #2563eb;
    padding-left: 8px;
}

.css-1iz6ik5 .css-wx2q63:has(button.displayOnHover svg.tabler-icon-pencil) .css-1ezgv1 {
    font-weight: bold !important;
}

/* Exclude read-only fields (css-1tobuy) */
.css-1iz6ik5 .css-1tobuy .css-qoso39,
.css-1iz6ik5 .css-1tobuy .css-947212 {
    background-color: transparent !important;
    border: none !important;
    width: auto !important;
}

.css-1iz6ik5 .css-1tobuy .css-qoso39 * {
    width: auto !important;
    pointer-events: auto !important;
}

.css-1iz6ik5 .css-1tobuy .css-16tuwpc {
    font-weight: normal !important;
}

/* Hide DELETE objeto relacionado en la relacion tema claro y oscuro para no borren por error */
.css-1t030jj:has(svg.tabler-icon-trash),
.css-1btgwuo:has(svg.tabler-icon-trash),
.css-1e9w63d:has(svg.tabler-icon-trash) {
    display: none !important;
}

/* Hide elements where ID contains "lastUpdateNota" */
.css-1tobuy:has([id*="lastUpdateNota"]),
.css-1tobuy:has([id*="lastUpdateRelation"]) {
    display: none !important;
}

/* ===== RELATION PICKER MODAL STYLES ===== */
/* Main picker container - centered on screen with full height control */
[id^="record-field-card-relation-picker"][role="listbox"] {
    width: 65vw !important;
    max-width: 840px !important;
    height: 80vh !important;
    max-height: 800px !important;
    min-height: 300px !important;
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
}

/* Force all parent containers to take full height and width */
[id^="record-field-card-relation-picker"][role="listbox"] .css-wf3sx5,
[id^="record-field-card-relation-picker"][role="listbox"] .css-39h30z,
[id^="record-field-card-relation-picker"][role="listbox"] .css-d8a3be,
[id^="record-field-card-relation-picker"][role="listbox"] .css-bmk3tx,
[id^="record-field-card-relation-picker"][role="listbox"] .css-1jbqzoh {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* The scrollable list container - takes all space minus search */
[id^="record-field-card-relation-picker"][role="listbox"] .css-qm33u7 {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    flex: 1 1 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
}

/* Items list wrapper - CRITICAL: Use block layout to prevent distribution */
[id^="record-field-card-relation-picker"][role="listbox"] .css-1vlzflq {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    height: auto !important;
}

/* Each individual item container */
[id^="record-field-card-relation-picker"][role="listbox"] .css-1c358af {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 8px !important;
    height: auto !important;
}

/* Menu items themselves */
[id^="record-field-card-relation-picker"][role="listbox"] .css-1efpsap {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    box-sizing: border-box !important;
    padding: 8px 12px !important;
}

/* Inner content of each item - ensure flex layout */
[id^="record-field-card-relation-picker"][role="listbox"] .css-tusdoy,
[id^="record-field-card-relation-picker"][role="listbox"] .e1g3mtjy4 {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Avatar circles - prevent shrinking */
[id^="record-field-card-relation-picker"][role="listbox"] .skj0go6 {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Text content wrapper - allow to grow */
[id^="record-field-card-relation-picker"][role="listbox"] .css-j14pec,
[id^="record-field-card-relation-picker"][role="listbox"] .eu6nqod0 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Title wrapper */
[id^="record-field-card-relation-picker"][role="listbox"] .css-1te43ul,
[id^="record-field-card-relation-picker"][role="listbox"] .e1g3mtjy1 {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* The actual text - keep truncation with ellipsis */
[id^="record-field-card-relation-picker"][role="listbox"] .s1a0c8w6 {
    width: 100% !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Hide the spacer that breaks layout */
[id^="record-field-card-relation-picker"][role="listbox"] .css-1qa5nim {
    display: none !important;
}

/* Search input section - pinned at bottom */
[id^="record-field-card-relation-picker"][role="listbox"] .css-12afo38 {
    width: 100% !important;
    max-width: 100% !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    box-sizing: border-box !important;
    padding: 12px !important;
    border-top: 1px solid #e0e0e0 !important;
    background: white !important;
    margin-top: auto !important;
}

[id^="record-field-card-relation-picker"][role="listbox"] .css-y7nkgp {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Scrollbar styling */
[id^="record-field-card-relation-picker"][role="listbox"] .css-qm33u7::-webkit-scrollbar {
    width: 8px !important;
}

[id^="record-field-card-relation-picker"][role="listbox"] .css-qm33u7::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
}

[id^="record-field-card-relation-picker"][role="listbox"] .css-qm33u7::-webkit-scrollbar-thumb {
    background: #888 !important;
    border-radius: 4px !important;
}

[id^="record-field-card-relation-picker"][role="listbox"] .css-qm33u7::-webkit-scrollbar-thumb:hover {
    background: #555 !important;
}
