/*
 * AhoraAjedrez — now-sidebar/styles.css
 *
 * REGLAS:
 * - Solo variables de main.css (--sidebar-w, --topbar-h, --bg, --text, --accent…)
 * - Solo variables de ahora-design-system.css para dark mode ([data-theme])
 * - Sin colores, anchos ni alturas hardcoded
 * - Sin lógica de drawer/overlay (main.css + nav.js)
 * - Sin animación de collapse (state.js lo gestiona con max-height)
 *
 * RESPONSABILIDAD: apariencia interna de la sidebar.
 * main.css controla: posición, ancho, top, margin del #ahora-main.
 */

/* ═══════════════════════════════════════════════════════════════
   ESTRUCTURA BASE
   Hereda posición de main.css (#ahora-sidebar: fixed, top, width)
   ═══════════════════════════════════════════════════════════════ */

#ahora-sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-soft) !important;
    z-index: 900;
    /* scrollbar refinada */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#ahora-sidebar::-webkit-scrollbar       { width: 4px; }
#ahora-sidebar::-webkit-scrollbar-track { background: transparent; }
#ahora-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* ═══════════════════════════════════════════════════════════════
   DIVIDER
   ═══════════════════════════════════════════════════════════════ */

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 14px;
}


/* ═══════════════════════════════════════════════════════════════
   SECCIONES COLAPSABLES
   ═══════════════════════════════════════════════════════════════ */

.now-sb-section {
    margin: 0;
}

/* Botón toggle de sección */
.now-sb-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 32px;
    padding: 0 14px 0 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 2px;
    gap: 6px;
}

.now-sb-toggle:hover .sidebar-section-title-txt {
    color: var(--text-primary);
}

/* Título de sección */
.sidebar-section-title-txt {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    flex: 1;
    text-align: left;
    transition: color var(--transition);
    /* Ocultar en modo mini */
    white-space: nowrap;
    overflow: hidden;
}

/* Flecha chevron */
.sidebar-toggle-arrow {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition), color var(--transition);
    line-height: 0;
}

/* Estado expandido: flecha apunta abajo */
.now-sb-toggle[aria-expanded="true"]  .sidebar-toggle-arrow { transform: rotate(90deg); }
/* Estado colapsado: flecha apunta a la derecha */
.now-sb-toggle[aria-expanded="false"] .sidebar-toggle-arrow { transform: rotate(-90deg); }

/* Cuerpo de sección — animación de collapse */
.sidebar-section-items {
    overflow: hidden;
    max-height: 800px;   /* suficiente para cualquier sección */
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}


/* ═══════════════════════════════════════════════════════════════
   ÍTEMS DE NAVEGACIÓN
   Reutiliza las clases .sidebar-item y .active del sistema original
   para que nav.js funcione sin cambios (initSidebarItems, markActiveItem)
   ═══════════════════════════════════════════════════════════════ */

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 14px 0 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

/* Ítem activo — acento dorado consistente con el sistema */
.sidebar-item.active {
    color: var(--accent);
    background: rgba(201, 162, 39, 0.08); /* --accent con alfa */
    font-weight: 500;
}

.sidebar-item.active .sidebar-icon {
    color: var(--accent);
}

/* Línea de acento izquierda en ítem activo */
.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

/* Icono del ítem */
.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
    color: inherit;
    line-height: 0;
}

/* Label del ítem */
.sidebar-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity var(--transition);
}


/* ═══════════════════════════════════════════════════════════════
   SLOTS DE FAVORITOS (placeholder visual — Fase 1)
   En Fase 3 se reemplaza por buscador inline
   ═══════════════════════════════════════════════════════════════ */

.now-sb-slot {
    cursor: pointer;
}

.now-sb-slot--empty {
    opacity: 0.5;
}

.now-sb-slot--empty:hover {
    opacity: 1;
}

.now-sb-slot-icon {
    font-size: 16px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1;
}

.now-sb-slot-label {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

/* Feedback "Próximamente…" (gestionado por state.js) */
.now-sb-slot--feedback .now-sb-slot-label {
    color: var(--text-light);
    font-style: normal;
}


/* ═══════════════════════════════════════════════════════════════
   FOOTER DE SIDEBAR
   ═══════════════════════════════════════════════════════════════ */

.now-sb-footer {
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.now-sb-footer .sidebar-item {
    font-size: 12px;
    color: var(--text-muted);
    height: 32px;
}

.now-sb-footer .sidebar-item:hover {
    background: none;
    color: var(--text-primary);
    text-decoration: underline;
}


/* ═══════════════════════════════════════════════════════════════
   MODO COLAPSADO (sidebar-mini: 72px)
   nav.js añade body.sidebar-collapsed en desktop
   main.css reduce #ahora-sidebar a var(--sidebar-mini)
   ═══════════════════════════════════════════════════════════════ */

body.sidebar-collapsed .now-sb-toggle           { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-section-title-txt { display: none; }
body.sidebar-collapsed .sidebar-toggle-arrow    { display: none; }
body.sidebar-collapsed .sidebar-section-items   { max-height: 800px !important; opacity: 1 !important; }
body.sidebar-collapsed .sidebar-label           { display: none; }
body.sidebar-collapsed .sidebar-item            { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-icon            { width: auto; }
body.sidebar-collapsed .now-sb-footer           { border-top: 1px solid var(--border); }

/* Tooltip en modo mini */
body.sidebar-collapsed .sidebar-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-mini) - 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 300;
}

body.sidebar-collapsed .sidebar-item:hover::after {
    opacity: 1;
}

/* Slots ocultos en modo mini */
body.sidebar-collapsed .now-sb-slot { display: none; }
body.sidebar-collapsed .sidebar-divider { margin: 4px 8px; }


/* ═══════════════════════════════════════════════════════════════
   DARK MODE — usando [data-theme="dark"] de ahora-design-system
   Solo override de variables que main.css no cubre directamente
   ═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] .sidebar-item.active {
    /* En dark el bg activo con acento dorado resulta más visible con más alfa */
    background: rgba(201, 162, 39, 0.12);
}

[data-theme="dark"] .now-sb-slot--empty {
    opacity: 0.4;
}

[data-theme="dark"] .now-sb-slot--empty:hover {
    opacity: 0.8;
}


/* ═══════════════════════════════════════════════════════════════
   ACCESIBILIDAD
   ═══════════════════════════════════════════════════════════════ */

.sidebar-item:focus-visible,
.now-sb-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-section-items,
    .sidebar-toggle-arrow,
    .sidebar-item,
    .sidebar-label {
        transition: none !important;
    }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — solo ajustes internos
   El drawer/overlay/transform está en main.css
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Slots visibles en mobile */
    .now-sb-slot { display: flex; }
}

/* ── Group label (Populares, etc.) ── */
.sidebar-group-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-muted);
    padding: 10px 16px 4px;
    opacity: .6;
}