/* =============================================================================
   Grupo Luminotecnia — base y componentes
   Depende de tokens.css. Ni un solo color hex acá: todo sale de var(--…),
   que es lo que hace que el tema oscuro funcione sin duplicar hojas de estilo.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* El atributo `hidden` tiene que ganarle a cualquier `display` de componente:
   sin esto, un .ms-count { display:inline-flex } se sigue viendo aunque JS lo
   marque como oculto. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -.02em;
    text-wrap: balance;
    margin: 0;
}

h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Quien pidió menos movimiento en el sistema, no recibe animaciones. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* --- Layout ---------------------------------------------------------------- */

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 18px; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- Barra superior -------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .brand {
    display: flex;
    align-items: baseline;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
}

.topbar .brand b { color: var(--accent); }
.topbar .spacer { flex: 1; }

.topnav { display: flex; gap: 2px; flex-wrap: wrap; }

.topnav-link {
    padding: 6px 11px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
}

.topnav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topnav-link.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.usermenu { display: flex; align-items: center; gap: 8px; }
.usermenu-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; }
    .topnav { order: 10; width: 100%; overflow-x: auto; }
    .usermenu-name { display: none; }
}

/* --- Pantallas sin navegación (login, error) ------------------------------- */

.bare-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.bare-main { width: 100%; max-width: 460px; }
.bare-theme { position: fixed; top: 16px; right: 16px; }
.auth-card { padding: 28px; }

/* --- Mensajes de una petición a la otra ------------------------------------ */

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 14px;
}

.flash svg { flex: none; margin-top: 2px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-crit { background: var(--crit-bg); color: var(--crit); }

/* --- Tarjetas -------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

/* --- Botones --------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* --- Pestañas --------------------------------------------------------------
   Para alternar entre dos o tres vistas de la misma sección (promociones y
   novedades). Son enlaces, no botones: cada pestaña es una URL propia y tiene
   que poder abrirse en otra solapa. */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}

.tab {
    padding: 9px 16px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.tab:hover { color: var(--ink); text-decoration: none; }

.tab.is-current { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Insignias ------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink-2);
}

.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* --- Formularios ----------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error { color: var(--crit); font-size: 12.5px; margin-top: 4px; }
.input[aria-invalid="true"] { border-color: var(--crit); }

/* --- Tablas ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunken); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--sunken); }
.table .num { text-align: right; font-family: var(--font-mono); font-size: 13px; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Una fila atenuada sigue siendo legible: se baja el contraste, no el tamaño.
   Un usuario inactivo tiene que poder leerse para poder reactivarlo. */
.table tr.is-muted td { opacity: .62; }

/* --- Encabezado de página y personas --------------------------------------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.person { display: flex; align-items: center; gap: 10px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex: none;
}

.avatar-lg { width: 64px; height: 64px; margin-bottom: 8px; display: block; }

.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
    background: var(--accent-soft);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
}

/* =============================================================================
   Multi-select con AJAX — el filtro por defecto del sistema
   =============================================================================
   Portado del filtro de gltmkt (_exec_filterbar.php) y pasado a AJAX.
   Buscador adentro, "Todo / Nada", botón Aplicar y chips de lo elegido.
   Nunca un <select multiple> suelto: no se puede buscar y en celular es inusable.
   ========================================================================== */

.ms-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.ms-bar-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    font-weight: 500;
}

.ms { position: relative; }

.ms-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.ms-toggle:hover { background: var(--surface-2); }
.ms-toggle[aria-expanded="true"] { border-color: var(--accent); }
.ms-toggle .ms-icon { color: var(--accent); display: inline-flex; }
.ms-toggle .ms-caret { color: var(--muted); transition: transform .15s ease; }
.ms-toggle[aria-expanded="true"] .ms-caret { transform: rotate(180deg); }

.ms-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 9px;
}

.ms-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 200;
    width: 280px;
    max-height: 420px;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
}

.ms-menu.is-open { display: flex; }

.ms-menu-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line-soft); }

.ms-search {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--sunken);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.ms-search:focus { outline: none; border-color: var(--accent); }

.ms-mini {
    padding: 5px 9px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink-2);
    font: inherit;
    font-size: 11.5px;
    white-space: nowrap;
    cursor: pointer;
}

.ms-mini:hover { background: var(--surface-2); }

.ms-options { flex: 1; overflow-y: auto; padding: 6px; max-height: 280px; }

.ms-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
}

.ms-opt:hover { background: var(--sunken); }
.ms-opt input { margin: 0; cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }
.ms-opt span { flex: 1; }
.ms-opt.is-hidden { display: none; }

.ms-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12.5px; font-style: italic; }

.ms-menu-foot { display: flex; justify-content: flex-end; gap: 6px; padding: 8px; border-top: 1px solid var(--line-soft); }

.ms-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
}

.ms-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.ms-chip-x:hover { background: color-mix(in srgb, var(--accent) 38%, transparent); }

.ms-clear { border: 0; background: transparent; color: var(--crit); font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.ms-clear:hover { background: var(--crit-bg); }

/* Estado de carga: la zona de resultados se atenúa pero no salta. */
.ms-results { position: relative; transition: opacity .15s ease; }
.ms-results[aria-busy="true"] { opacity: .45; pointer-events: none; }

/* En celular el menú ocupa el ancho disponible y no se sale de la pantalla. */
@media (max-width: 560px) {
    .ms { position: static; }
    .ms-menu { width: calc(100vw - 40px); left: 0; right: 0; }
    .ms-bar { padding: 10px; }
}

/* --- Interruptor de tema --------------------------------------------------- */

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }

.theme-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* --- Editor de horarios de sucursal ---------------------------------------- */

.hours-table td { vertical-align: middle; }
.hours-pair { display: flex; align-items: center; gap: 8px; }
.hours-pair .input { width: auto; min-width: 110px; padding: 6px 9px; font-size: 13px; }

@media (max-width: 640px) {
    .hours-pair { flex-wrap: wrap; }
    .hours-pair .input { min-width: 92px; }
}

/* --- Ficha del código QR ---------------------------------------------------- */

.qr-card { display: flex; gap: 26px; align-items: flex-start; flex-wrap: wrap; }
.qr-meta { flex: 1; min-width: 260px; }

/* Fondo blanco fijo: un QR sobre fondo oscuro no lo lee ningún celular, así
   que esta es la única superficie del sistema que NO sigue al tema. */
.qr-figure {
    background: #FFFFFF;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    line-height: 0;
}

.token {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: .06em;
    background: var(--sunken);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 2px 7px;
}

.token-lg { font-size: 17px; padding: 5px 11px; }

/* --- Miniaturas e imágenes del catálogo (admin) ----------------------------- */

.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--sunken); }

.thumb-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line);
    color: var(--muted);
}

.checkline { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; cursor: pointer; font-size: 14px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

.image-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--sunken);
}

.image-item img { display: block; width: 100%; height: 130px; object-fit: cover; }
.image-actions { display: flex; flex-direction: column; gap: 4px; padding: 8px; align-items: flex-start; }
