/* Paridad visual con legacy Multifact (Bootstrap 4 + tema #5D5ABF) */
.legacy-bill-actions {
    position: relative;
    display: inline-block;
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    min-width: 6.5rem;
}

.legacy-bill-actions-cell {
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-width: 6.5rem;
    overflow: visible;
    padding-left: 0.75rem;
}

.legacy-bill-actions-cell .btn-acciones {
    min-width: 5.75rem;
    white-space: nowrap;
}

.legacy-bill-email-cell {
    min-width: 6.5rem;
    max-width: 8rem;
    line-height: 1.15;
    padding-right: 0.5rem;
}

.legacy-bill-email-cell .legacy-email-sent {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: #059669;
    white-space: nowrap;
}

.legacy-bill-email-cell .legacy-email-sent i {
    font-size: 0.8rem;
}

.legacy-bill-email-cell .legacy-email-badge-inline {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 500;
    white-space: normal;
    word-break: break-word;
    padding: 0.2em 0.45em;
    border-radius: 0.2rem;
    background-color: #28a745;
    color: #fff;
    line-height: 1.15;
}

.legacy-bill-email-cell .legacy-email-badge-inline i {
    font-size: 0.575rem;
    margin-right: 0.15rem;
}

.legacy-bill-ai-documents-cell {
    min-width: 9rem;
    max-width: 12rem;
    line-height: 1.2;
}

.legacy-bill-ai-documents-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.legacy-bill-ai-documents-cell .btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    line-height: 1.35;
    border-radius: 0.2rem;
    text-decoration: none;
    white-space: nowrap;
}

.legacy-bill-ai-documents-cell .btn-outline-primary {
    color: #5d5abf;
    border-color: #5d5abf;
    background-color: transparent;
}

.legacy-bill-ai-documents-cell .btn-outline-primary:hover {
    color: #fff;
    background-color: #5d5abf;
}

.legacy-bill-ai-documents-cell .btn-outline-success {
    color: #28a745;
    border-color: #28a745;
    background-color: transparent;
}

.legacy-bill-ai-documents-cell .btn-outline-success:hover {
    color: #fff;
    background-color: #28a745;
}

.legacy-bill-ai-documents-cell .text-muted {
    color: #6c757d !important;
}

.legacy-bill-ai-documents-cell .btn i {
    margin-right: 0.15rem;
    font-size: 0.7rem;
}

.legacy-bill-actions .legacy-email-badge {
    margin-bottom: 0.25rem;
}

.legacy-bill-actions .legacy-email-badge .badge {
    font-size: 0.7rem;
    white-space: normal;
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 0.25rem;
}

.legacy-bill-actions .badge-success {
    background-color: #28a745;
    color: #fff;
}

.legacy-bill-actions .badge-secondary {
    background-color: #6c757d;
    color: #fff;
}

.legacy-bill-actions .btn-acciones {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    background-color: #5d5abf;
    color: #fff;
    cursor: pointer;
}

.legacy-bill-actions .btn-acciones:hover {
    background-color: #4f4cad;
    color: #fff;
}

.legacy-bill-actions .legacy-bill-actions-panel,
.legacy-bill-actions-panel.legacy-bill-actions-portal {
    position: fixed;
    z-index: 99999;
    display: none;
    min-width: 12rem;
    max-width: 22rem;
    max-height: 32rem;
    overflow-y: auto;
    padding: 0.5rem 0;
    font-size: 1rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff !important;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
}

.legacy-bill-actions .legacy-bill-actions-panel.is-open,
.legacy-bill-actions-panel.legacy-bill-actions-portal.is-open {
    display: block;
}

.legacy-bill-actions-portal .dropdown-item,
.legacy-bill-actions-panel .dropdown-item,
.legacy-bill-actions .dropdown-item {
    display: block;
    width: 100%;
    padding: 0.25rem 1.5rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.legacy-bill-actions-portal .dropdown-divider,
.legacy-bill-actions .dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #e9ecef;
}

.legacy-bill-actions-portal .dropdown-header,
.legacy-bill-actions .dropdown-header {
    display: block;
    padding: 0.5rem 1.5rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: #6c757d;
    white-space: nowrap;
    font-weight: 600;
}

.legacy-bill-actions-portal .dropdown-item:hover,
.legacy-bill-actions-portal .dropdown-item:focus,
.legacy-bill-actions .dropdown-item:hover,
.legacy-bill-actions .dropdown-item:focus {
    color: #16181b;
    text-decoration: none;
    background-color: #f8f9fa;
}

.legacy-bill-actions-portal .dropdown-item.text-primary,
.legacy-bill-actions .dropdown-item.text-primary {
    color: #5d5abf !important;
}

.legacy-bill-actions-portal .dropdown-item.text-info,
.legacy-bill-actions .dropdown-item.text-info {
    color: #17a2b8 !important;
}

.legacy-bill-actions-portal .dropdown-item.text-success,
.legacy-bill-actions .dropdown-item.text-success {
    color: #28a745 !important;
}

.legacy-bill-actions-portal .dropdown-item.text-warning,
.legacy-bill-actions .dropdown-item.text-warning {
    color: #ffc107 !important;
}

.legacy-bill-actions-portal .dropdown-item i,
.legacy-bill-actions .dropdown-item i {
    width: 1.1rem;
    margin-right: 0.35rem;
    text-align: center;
}

.legacy-bill-actions-portal .deliverable-row,
.legacy-bill-actions .deliverable-row {
    white-space: normal;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.legacy-bill-actions .btn-sm {
    padding: 0.15rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
}

.legacy-bill-actions .btn-outline-primary {
    color: #5d5abf;
    border: 1px solid #5d5abf;
    background-color: transparent;
}

.legacy-bill-actions .btn-outline-primary:hover {
    color: #fff;
    background-color: #5d5abf;
}

.legacy-bill-actions .btn-outline-success {
    color: #28a745;
    border: 1px solid #28a745;
    background-color: transparent;
}

.legacy-bill-actions .btn-outline-success:hover {
    color: #fff;
    background-color: #28a745;
}

.legacy-bill-actions .text-muted {
    color: #6c757d !important;
}

.legacy-bill-actions .text-danger {
    color: #dc3545 !important;
}

/* ── Modal backdrop ──────────────────────────────────────────────────────── */
/* The modal is teleported to <body> via x-teleport, so selectors that use
   .legacy-bill-actions as parent would break. We use .legacy-bill-modal-portal
   as a standalone anchor for everything inside the teleported modal. */

.legacy-bill-actions .legacy-modal-backdrop,
.legacy-bill-modal-portal.legacy-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* ── Modal box ───────────────────────────────────────────────────────────── */
.legacy-bill-actions .legacy-modal,
.legacy-bill-modal-portal .legacy-modal {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
}

/* ── Modal header ────────────────────────────────────────────────────────── */
.legacy-bill-actions .legacy-modal > h5,
.legacy-bill-modal-portal .legacy-modal > h5 {
    margin: 0;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* ── Modal body ──────────────────────────────────────────────────────────── */
.legacy-bill-actions .legacy-modal-body,
.legacy-bill-modal-portal .legacy-modal-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.legacy-bill-actions .legacy-modal-body label,
.legacy-bill-modal-portal .legacy-modal-body label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

.legacy-bill-actions .legacy-modal-body .legacy-modal-hint,
.legacy-bill-modal-portal .legacy-modal-body .legacy-modal-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: -0.25rem;
}

.legacy-bill-actions .legacy-modal-body .legacy-modal-checkbox,
.legacy-bill-modal-portal .legacy-modal-body .legacy-modal-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}

.legacy-bill-actions .legacy-modal-body .legacy-modal-checkbox input[type="checkbox"],
.legacy-bill-modal-portal .legacy-modal-body .legacy-modal-checkbox input[type="checkbox"] {
    width: auto;
    display: inline;
    margin: 0;
}

.legacy-bill-actions .legacy-modal input,
.legacy-bill-actions .legacy-modal select,
.legacy-bill-actions .legacy-modal textarea,
.legacy-bill-modal-portal .legacy-modal input,
.legacy-bill-modal-portal .legacy-modal select,
.legacy-bill-modal-portal .legacy-modal textarea {
    display: block;
    width: 100%;
    margin-top: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.legacy-bill-actions .legacy-modal input:focus,
.legacy-bill-actions .legacy-modal select:focus,
.legacy-bill-actions .legacy-modal textarea:focus,
.legacy-bill-modal-portal .legacy-modal input:focus,
.legacy-bill-modal-portal .legacy-modal select:focus,
.legacy-bill-modal-portal .legacy-modal textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ── Modal footer / actions ──────────────────────────────────────────────── */
.legacy-bill-actions .legacy-modal-actions,
.legacy-bill-modal-portal .legacy-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.legacy-bill-actions .legacy-modal-actions button,
.legacy-bill-modal-portal .legacy-modal-actions button {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.legacy-bill-actions .legacy-modal-actions .btn-cancel,
.legacy-bill-modal-portal .legacy-modal-actions .btn-cancel {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.legacy-bill-actions .legacy-modal-actions .btn-cancel:hover,
.legacy-bill-modal-portal .legacy-modal-actions .btn-cancel:hover {
    background: #f3f4f6;
}

.legacy-bill-actions .legacy-modal-actions .btn-acciones,
.legacy-bill-modal-portal .legacy-modal-actions .btn-acciones {
    background: #6366f1;
    color: #fff;
    border: 1px solid #6366f1;
}

.legacy-bill-actions .legacy-modal-actions .btn-acciones:hover,
.legacy-bill-modal-portal .legacy-modal-actions .btn-acciones:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.legacy-bill-actions .legacy-modal-actions .btn-danger,
.legacy-bill-modal-portal .legacy-modal-actions .btn-danger {
    background: #dc2626;
    color: #fff;
    border: 1px solid #dc2626;
}

.legacy-bill-actions .legacy-modal-actions .btn-danger:hover,
.legacy-bill-modal-portal .legacy-modal-actions .btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.legacy-bill-actions .legacy-modal-actions .btn-danger:disabled,
.legacy-bill-modal-portal .legacy-modal-actions .btn-danger:disabled,
.legacy-bill-actions .legacy-modal-actions .btn-acciones:disabled,
.legacy-bill-modal-portal .legacy-modal-actions .btn-acciones:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.legacy-bill-actions .d-flex {
    display: flex !important;
}

.legacy-bill-actions .flex-column {
    flex-direction: column !important;
}

.legacy-bill-actions .flex-grow-1 {
    flex-grow: 1 !important;
}

.legacy-bill-actions .justify-content-between {
    justify-content: space-between !important;
}

.legacy-bill-actions .align-items-start {
    align-items: flex-start !important;
}

.legacy-bill-actions .align-items-end {
    align-items: flex-end !important;
}

.legacy-bill-actions .mt-1 {
    margin-top: 0.25rem !important;
}

.legacy-bill-actions .py-0 {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.legacy-bill-actions .px-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.legacy-bill-actions .py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.legacy-bill-actions .d-block {
    display: block !important;
}

.legacy-bill-actions .text-secondary {
    color: #6c757d !important;
}

/* Filament table: allow action dropdown triggers to stay visible */
.fi-ta-cell:has(.legacy-bill-actions-cell),
.fi-ta-cell:has(.legacy-bill-email-cell) {
    overflow: visible !important;
    position: relative;
}

/* Bills list: copy cell values without row navigation to preview */
.fi-resource-facturas .fi-ta-row .fi-ta-cell {
    cursor: text;
    user-select: text;
}

.fi-resource-facturas .fi-ta-row .fi-ta-cell:has(.legacy-bill-actions-cell),
.fi-resource-facturas .fi-ta-row .fi-ta-cell:has(.legacy-bill-ai-documents-cell),
.fi-resource-facturas .fi-ta-row .fi-ta-cell:has(.legacy-bill-email-cell),
.fi-resource-facturas .fi-ta-row .fi-ta-cell:has(input[type='checkbox']) {
    cursor: default;
    user-select: none;
}
