/* ==========================================================
   tautocomplete - estilos (paleta ERP Educa)
   Temas: default (.adropdown), classic (.aclassic), white (.awhite)
   ========================================================== */

/* ---------- Contenedor, paleta e input ---------- */
.acontainer {
    /* paleta del proyecto (con respaldo) */
    --tac-primary: #2a2725;
    --tac-primary-light: var(--eed-primary-light, #2563eb);
    --tac-secondary: var(--eed-secondary, #64748b);
    --tac-secondary-light: var(--eed-secondary-light, #94a3b8);
    --tac-accent: var(--eed-accent, #f59e0b);

    /* roles */
    --tac-ring: #4ade80;          /* anillo de foco */
    --tac-border: #d3dbe8;
    --tac-text: #0f172a;

    /* títulos de columna */
    --tac-head-bg: var(--tac-primary);
    --tac-head-fg: #ffffff;

    /* filas */
    --tac-row-fg: var(--tac-secondary);
    --tac-row-line: #edf1f7;
    --tac-row-zebra: transparent;

    /* fila activa (mouse o teclado) */
    --tac-sel-bg: #d6e3ff;
    --tac-sel-fg: var(--tac-primary);

    /* texto coincidente */
    --tac-hl-bg: rgba(245, 158, 11, .28);
    --tac-hl-fg: #7c3a00;
    --tac-hl-sel-bg: rgba(245, 158, 11, .40);
    --tac-hl-sel-fg: #5c2a00;

    --tac-foot-bg: #f6f8fc;
    --tac-radius: 12px;
    --tac-font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

    position: relative;
    display: inline-block;
    max-width: 100%;
}

.acontainer input {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 10px 38px;
    border: 1px solid var(--tac-border);
    border-radius: 10px;
    background-color: #fff;
    /* lupa a la izquierda */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
    color: var(--tac-text);
    font-family: var(--tac-font);
    outline: 0;
    /* solo borde y anillo, rapidísimo: el fondo nunca se anima */
    transition: border-color .12s ease, box-shadow .12s ease;
}

.acontainer input::placeholder {
    color: var(--tac-secondary-light);
}

.acontainer input:hover {
    border-color: var(--tac-secondary-light);
}

.acontainer input:focus,
.acontainer input.inputfocus {
    border-color: var(--tac-primary-light);
    box-shadow: 0 0 0 3px var(--tac-ring);
    outline: none;
}

.acontainer input.inputfocus {
    position: relative;
    z-index: 1000;
}

.acontainer input::-ms-clear {
    width: 0;
    height: 0;
}

/* Cargando: lupa + spinner SVG embebido (ya no se necesita img/loading.gif) */
.acontainer input.loadingAG {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a9 9 0 0 1 9 9' fill='none' stroke='%23f59e0b' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='.7s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: left 12px center, right 12px center;
    background-size: 16px 16px, 16px 16px;
}

/* Botón "×" para limpiar (solo aparece si hay texto y no está cargando) */
.acontainer .tac-clear {
    display: none;
    position: absolute;
    top: 50%;
    right: 9px;
    z-index: 1001;
    width: 22px;
    height: 22px;
    margin-top: -12px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--tac-secondary-light);
    font: 17px/1 var(--tac-font);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.acontainer .tac-clear.on {
    display: flex;
}

.acontainer .tac-clear:hover {
    background: #eaf0fb;
    color: var(--tac-primary);
}

.acontainer input.loadingAG ~ .tac-clear {
    display: none;
}

/* ---------- Panel desplegable (estructura común) ---------- */
.adropdown,
.aclassic,
.awhite {
    box-sizing: border-box;
    position: absolute;
    top: 100%;
    left: 0;
    display: block;
    margin: 8px 0 0;
    padding: 0;
    max-width: calc(100vw - 16px);
    max-height: 360px;
    overflow-x: hidden;
    overflow-y: auto;
    text-align: left;
    background: #fff;                       
    border: 1px solid var(--tac-border);    
    border-radius: var(--tac-radius);
    box-shadow: 0 18px 40px -12px rgba(0, 35, 151, .26), 0 6px 14px -6px rgba(15, 23, 42, .14);
    transform-origin: top center;
    scrollbar-width: thin;
    scrollbar-color: var(--tac-secondary-light) transparent;
    -webkit-overflow-scrolling: touch;
}

/* cerrado = no existe (sin fundidos ni estados intermedios) */
.adropdown:not(.highlight),
.aclassic:not(.highlight),
.awhite:not(.highlight) {
    display: none;
}

.adropdown.highlight,
.aclassic.highlight,
.awhite.highlight {
    z-index: 999;
    animation: tac-in .14s cubic-bezier(.2, .8, .2, 1);
}

/* abre hacia arriba cuando no cabe debajo */
.adropdown.tac-up,
.aclassic.tac-up,
.awhite.tac-up {
    margin: 0 0 8px;
    transform-origin: bottom center;
}

.adropdown.highlight.tac-up,
.aclassic.highlight.tac-up,
.awhite.highlight.tac-up {
    animation-name: tac-in-up;
}

/* Entrada: solo desplazamiento y escala, sin tocar la opacidad */
@keyframes tac-in {
    from { transform: translateY(-6px) scale(.985); }
    to   { transform: none; }
}

@keyframes tac-in-up {
    from { transform: translateY(6px) scale(.985); }
    to   { transform: none; }
}

/* Anula cualquier transición global del sitio dentro del panel */
.adropdown,
.adropdown *,
.aclassic,
.aclassic *,
.awhite,
.awhite * {
    -webkit-transition: none !important;
    transition: none !important;
}

.adropdown *,
.aclassic *,
.awhite * {
    -webkit-animation: none !important;
    animation: none !important;
}

/* Barra de scroll discreta (Chrome, Edge, Safari) */
.adropdown::-webkit-scrollbar,
.aclassic::-webkit-scrollbar,
.awhite::-webkit-scrollbar {
    width: 8px;
}

.adropdown::-webkit-scrollbar-thumb,
.aclassic::-webkit-scrollbar-thumb,
.awhite::-webkit-scrollbar-thumb {
    border: 2px solid #fff;
    border-radius: 8px;
    background: #cbd5e1;
}

.adropdown::-webkit-scrollbar-thumb:hover,
.aclassic::-webkit-scrollbar-thumb:hover,
.awhite::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- Tabla ---------- */
.adropdown table,
.aclassic table,
.awhite table {
    display: none;
    width: 100% !important;                 /* anula el ancho inline del plugin */
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    color: var(--tac-row-fg);
    font-family: var(--tac-font);
    font-size: 12px;
    cursor: pointer;
}

/* Títulos de columna: bloque sólido de color, fijo al hacer scroll */
.adropdown th,
.aclassic th,
.awhite th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 14px;
    background: var(--tac-head-bg);
    color: var(--tac-head-fg);
    border: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    text-align: left;
}

/* Filas */
.adropdown td,
.aclassic td,
.awhite td {
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--tac-row-line);
    color: var(--tac-row-fg);
    line-height: 1.35;
    text-align: left;
    vertical-align: middle;
}

/* la columna de texto principal destaca; el resto queda como dato secundario */
.adropdown td:nth-child(2),
.aclassic td:nth-child(2),
.awhite td:nth-child(2) {
    color: var(--tac-text);
    font-weight: 500;
}

.adropdown td:first-child,
.aclassic td:first-child,
.awhite td:first-child {
    font-variant-numeric: tabular-nums;
}

.adropdown tbody tr:last-child td,
.aclassic tbody tr:last-child td,
.awhite tbody tr:last-child td {
    border-bottom: 0;
}

.adropdown tbody tr:nth-child(even) td,
.aclassic tbody tr:nth-child(even) td,
.awhite tbody tr:nth-child(even) td {
    background: var(--tac-row-zebra);
}

/* Fila activa: la misma para mouse y teclado */
.adropdown tbody tr.selectedxx td,
.aclassic tbody tr.selectedxx td,
.awhite tbody tr.selectedxx td {
    background: var(--tac-sel-bg);
    color: var(--tac-sel-fg);
    font-weight: 600;
}

/* Texto coincidente: marcador ámbar */
.word-highlight {
    padding: 0 2px;
    margin: 0 -1px;
    border-radius: 3px;
    background: var(--tac-hl-bg);
    color: var(--tac-hl-fg);
    font-weight: 700;
}

.selectedxx .word-highlight {
    background: var(--tac-hl-sel-bg);
    color: var(--tac-hl-sel-fg);
}

/* Sin resultados */
.adropdown table caption,
.aclassic table caption,
.awhite table caption {
    caption-side: bottom;
    display: none;
    padding: 22px 14px;
    color: var(--tac-secondary);
    font-size: 13px;
    text-align: center;
}

/* Pie informativo fijo: cantidad de resultados y atajos (texto que arma el JS) */
.adropdown.highlight:not(.tac-empty)::after,
.aclassic.highlight:not(.tac-empty)::after,
.awhite.highlight:not(.tac-empty)::after {
    content: attr(data-info);
    position: sticky;
    bottom: 0;
    display: block;
    padding: 8px 14px;
    background: var(--tac-foot-bg);
    border-top: 1px solid var(--tac-row-line);
    color: var(--tac-secondary);
    font-family: var(--tac-font);
    font-size: 11px;
    line-height: 1.2;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================
   Tema "default": encabezado azul corporativo
   (usa los valores base de .acontainer)
   ========================================================== */

/* ==========================================================
   Tema "classic": encabezado gris pizarra y filas alternadas
   ========================================================== */
.aclassic {
    --tac-radius: 10px;
    --tac-head-bg: #334155;
    --tac-row-zebra: #f7f9fc;
}

/* ==========================================================
   Tema "white": sin borde, esquinas amplias, fila activa sólida
   ========================================================== */
.awhite {
    --tac-radius: 16px;
    --tac-head-bg: #ffffff;
    --tac-head-fg: var(--tac-primary);
    --tac-foot-bg: #ffffff;
    --tac-sel-bg: var(--tac-primary);
    --tac-sel-fg: #ffffff;
    --tac-hl-sel-bg: rgba(251, 191, 36, .35);
    --tac-hl-sel-fg: #fde68a;

    border: 0;
    box-shadow: 0 20px 44px -12px rgba(0, 35, 151, .32), 0 0 0 1px rgba(15, 23, 42, .06);
}

.awhite th {
    border-bottom: 2px solid var(--tac-primary);
}

.awhite td {
    border-bottom-color: transparent;
}

.awhite tbody tr.selectedxx td:nth-child(2) {
    font-weight: 700;
}

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 480px) {
    .acontainer {
        display: block;
        width: 100% !important;
    }

    .adropdown td,
    .aclassic td,
    .awhite td {
        padding: 12px 14px;                 /* zona táctil más cómoda */
    }
}

/* ---------- Accesibilidad: sin animación si el usuario lo pide ---------- */
@media (prefers-reduced-motion: reduce) {
    .adropdown.highlight,
    .aclassic.highlight,
    .awhite.highlight {
        animation: none;
    }
}