/* Modernización transversal de formularios, modales, registros y acciones.
   No modifica reglas de negocio ni consultas de los módulos. */
body.admin-premium.af-forms-ready {
    --af-form-border: #d9e2ee;
    --af-form-text: #10223a;
    --af-form-muted: #687991;
    --af-form-surface: #ffffff;
    --af-form-soft: #f7f9fc;
    --af-form-error: #c83d4f;
    --af-form-success: #11875d;
    --af-form-warning: #d98b12;
}

.admin-main form.af-modern-form { min-width: 0; }
.admin-main form.af-modern-form label:not(.af-action):not(.switch):not(.toggle):not(.inline-flex) {
    color: var(--af-form-text);
    font-weight: 800;
    line-height: 1.35;
}
.admin-main form.af-modern-form label > .af-label-icon {
    width: 16px;
    margin-right: 6px;
    color: var(--brand-primary);
    text-align: center;
}
.admin-main .af-optional {
    display: inline-flex;
    margin-left: 6px;
    color: #94a3b8;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    vertical-align: middle;
}

.admin-main form.af-modern-form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]),
.admin-main form.af-modern-form select,
.admin-main form.af-modern-form textarea {
    min-height: 43px;
    border-color: var(--af-form-border);
    border-radius: 10px;
    background-color: #fff;
    color: var(--af-form-text);
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.admin-main form.af-modern-form textarea { min-height: 90px; resize: vertical; }
.admin-main .af-password-wrap { position: relative; }
.admin-main .af-password-wrap input[type="password"],
.admin-main .af-password-wrap input[type="text"] { padding-right: 44px !important; }
.admin-main .af-password-toggle {
    position: absolute; top: 50%; right: 6px; width: 34px; height: 34px; transform: translateY(-50%);
    display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #64748b; cursor: pointer;
}
.admin-main .af-password-toggle:hover { background: #f1f5f9; color: var(--brand-primary); }
.admin-main form.af-modern-form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):focus,
.admin-main form.af-modern-form select:focus,
.admin-main form.af-modern-form textarea:focus {
    outline: none;
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 4px rgba(var(--brand-primary-rgb), .1) !important;
}
.admin-main form.af-modern-form input[aria-invalid="true"],
.admin-main form.af-modern-form select[aria-invalid="true"],
.admin-main form.af-modern-form textarea[aria-invalid="true"] {
    border-color: var(--af-form-error) !important;
    box-shadow: 0 0 0 4px rgba(200, 61, 79, .08) !important;
}
.admin-main form.af-modern-form input::placeholder,
.admin-main form.af-modern-form textarea::placeholder {
    color: #98a2b3;
    opacity: 1;
    font-weight: 400;
}
.admin-main form.af-modern-form input:focus::placeholder,
.admin-main form.af-modern-form textarea:focus::placeholder { color: transparent; }
.admin-main .af-field-error {
    display: block;
    min-height: 0;
    margin-top: 5px;
    color: var(--af-form-error);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.35;
}
.admin-main .af-field-error:not(:empty) { min-height: 16px; }
.admin-main form.af-modern-form small,
.admin-main form.af-modern-form .text-xs.text-gray-500,
.admin-main form.af-modern-form .text-xs.text-slate-500 { line-height: 1.45; }

/* Modales: ancho consistente, scroll interno y controles visibles. */
.af-modern-modal { padding: 16px !important; }
.af-modern-modal > .af-modern-modal-panel,
.af-modern-modal .af-modern-modal-panel {
    width: min(760px, calc(100vw - 28px)) !important;
    max-width: 760px !important;
    max-height: 88vh !important;
    overflow: hidden !important;
    border-radius: 18px !important;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .3) !important;
}
.af-modern-modal .af-modal-scroll-body {
    max-height: calc(88vh - 128px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.af-modern-modal .af-modal-scroll-body::-webkit-scrollbar { width: 8px; }
.af-modern-modal .af-modal-scroll-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.af-modern-modal .af-modal-category {
    display: block; margin-bottom: 4px; color: var(--brand-primary); font-size: 9px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase;
}
.af-modern-modal .af-modal-sticky-header { position: sticky; top: 0; z-index: 3; background: #fff; }
.af-modern-modal .af-modal-sticky-footer { position: sticky; bottom: 0; z-index: 3; background: #fff; border-top: 1px solid #e5eaf1; }

/* Tablas y registros. */
.admin-main .af-table-scroll { width: 100%; overflow-x: auto; border-radius: 0 0 14px 14px; }
.admin-main table.af-modern-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.admin-main table.af-modern-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #edf3f9 !important;
    color: #334155 !important;
    font-size: 10px !important;
    font-weight: 900 !important;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}
.admin-main table.af-modern-table tbody tr:nth-child(even) { background: #fbfdff; }
.admin-main table.af-modern-table tbody tr:hover { background: rgba(var(--brand-primary-rgb), .045) !important; }
.admin-main table.af-modern-table td { vertical-align: middle; }
.admin-main .dataTables_wrapper .dataTables_length select {
    min-width: 94px;
    height: 38px;
    border: 1px solid var(--af-form-border);
    border-radius: 9px;
    background: #fff;
    color: #334155;
}
.admin-main .dataTables_wrapper .dataTables_info { color: #64748b; font-size: 11px; }
.admin-main .dataTables_wrapper .dataTables_paginate { display: flex; align-items: center; justify-content: flex-end; gap: 3px; flex-wrap: wrap; }

/* Paleta semántica uniforme para iconos de acciones. */
.admin-main .af-colored-action,
.admin-main .af-btn-icon.af-colored-action,
.admin-main button.af-colored-action,
.admin-main a.af-colored-action {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none !important;
    transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}
.admin-main .af-colored-action:hover { transform: translateY(-1px); filter: brightness(.97); box-shadow: 0 6px 15px rgba(15,23,42,.09); }
.admin-main .af-action-edit { color: #1d4ed8 !important; background: #eff6ff !important; border-color: #bfdbfe !important; }
.admin-main .af-action-whatsapp { color: #047857 !important; background: #ecfdf5 !important; border-color: #a7f3d0 !important; }
.admin-main .af-action-delete { color: #b91c1c !important; background: #fff1f2 !important; border-color: #fecdd3 !important; }
.admin-main .af-action-renew { color: #b45309 !important; background: #fffbeb !important; border-color: #fde68a !important; }
.admin-main .af-action-copy { color: #6d28d9 !important; background: #f5f3ff !important; border-color: #ddd6fe !important; }
.admin-main .af-action-view { color: #0369a1 !important; background: #f0f9ff !important; border-color: #bae6fd !important; }
.admin-main .af-action-regenerate { color: #c2410c !important; background: #fff7ed !important; border-color: #fed7aa !important; }
.admin-main .af-action-download { color: #0f766e !important; background: #f0fdfa !important; border-color: #99f6e4 !important; }
.admin-main .af-action-neutral { color: #475569 !important; background: #f8fafc !important; border-color: #dbe3ec !important; }
.admin-main .af-actions, .admin-main td:last-child .flex { justify-content: center; align-items: center; }

.admin-main .af-submit-busy { pointer-events: none; opacity: .7; }
.admin-main .af-submit-busy .fa-spinner { animation: af-spin .8s linear infinite; }
@keyframes af-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .af-modern-modal { padding: 8px !important; }
    .af-modern-modal > .af-modern-modal-panel,
    .af-modern-modal .af-modern-modal-panel { width: calc(100vw - 16px) !important; max-height: 94vh !important; border-radius: 14px !important; }
    .af-modern-modal .af-modal-scroll-body { max-height: calc(94vh - 118px); }
    .admin-main .dataTables_wrapper .dataTables_paginate { justify-content: center; }
}

/* Corrección de regresión: los botones principales no deben expandirse como barras. */
.admin-main .af-heading { align-items: center; }
.admin-main .af-heading-main { flex: 1 1 auto; min-width: 0; }
.admin-main .af-heading-actions {
    width: auto !important;
    max-width: 56%;
    flex: 0 1 auto !important;
    justify-content: flex-end;
    align-self: center;
}
.admin-main .af-heading-actions .af-btn {
    width: auto !important;
    min-width: max-content;
    flex: 0 0 auto !important;
    white-space: nowrap;
}
@media (max-width: 900px) {
    .admin-main .af-heading { align-items: flex-start; }
    .admin-main .af-heading-actions { max-width: 100%; justify-content: flex-start; }
}
@media (max-width: 720px) {
    .admin-main .af-heading-actions { width: 100% !important; }
    .admin-main .af-heading-actions .af-btn { width: auto !important; min-width: 0; flex: 1 1 150px !important; }
}



/* Cierre visual 8.2: los botones de acción de las cabeceras son compactos en escritorio. */
@media (min-width: 761px) {
    body.admin-premium .admin-main .af-heading-actions {
        width: auto !important;
        max-width: 560px !important;
        flex: 0 0 auto !important;
        justify-content: flex-end !important;
    }
    body.admin-premium .admin-main .af-heading-actions .af-btn {
        width: auto !important;
        inline-size: max-content !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
    }
}
