/* =============================================================================
   🧬 GAJE — static/css/sidebar.css
   Barra Lateral & Cajón (Drawer) de Historial y Sesiones con Soporte Tri-Theme
   ============================================================================= */

/* ── Backdrop difuminado para Drawer Móvil ── */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Contenedor Drawer del Sidebar ── */
.sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    height: 100%;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: #141416;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.55);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.sidebar-drawer.open {
    transform: translateX(0);
}

/* ── Estructura Interna del Sidebar ── */
.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-color, #0a84ff);
    font-weight: 700;
    font-size: 0.86rem;
    letter-spacing: 0.04em;
    font-family: var(--mono, monospace);
}

.sidebar-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #a1a1aa);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-icon-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* ── Botón Principal Nueva Conversación ── */
.sidebar-action-row {
    padding: 0.9rem 1.15rem 0.5rem;
}

.sidebar-primary-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(10, 132, 255, 0.2) 0%, rgba(94, 92, 230, 0.2) 100%);
    border: 1px solid rgba(10, 132, 255, 0.4);
    color: #ffffff;
    font-family: var(--sans, sans-serif);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.15);
}

.sidebar-primary-btn:hover {
    background: linear-gradient(135deg, rgba(10, 132, 255, 0.35) 0%, rgba(94, 92, 230, 0.35) 100%);
    border-color: var(--accent-color, #0a84ff);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.25);
}

.sidebar-primary-btn:active {
    transform: translateY(0);
}

/* ── Lista de Sesiones ── */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.35rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #71717a);
    font-family: var(--mono, monospace);
}

.sidebar-badge {
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.68rem;
    color: var(--text-muted, #a1a1aa);
}

.sidebar-sessions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-session-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-session-item.active {
    background: rgba(10, 132, 255, 0.15);
    border-color: rgba(10, 132, 255, 0.4);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.session-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-color, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-session-item.active .session-title {
    color: var(--accent-color, #0a84ff);
    font-weight: 600;
}

.session-time {
    font-size: 0.68rem;
    color: var(--text-muted, #71717a);
    font-family: var(--mono, monospace);
}

/* ── Buscador de Historial ── */
.sidebar-search-row {
    padding: 0 0.8rem 0.5rem;
}

.sidebar-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0 8px;
    transition: all 0.2s ease;
}

.sidebar-search-wrapper:focus-within {
    border-color: var(--accent-color, #0a84ff);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
}

.sidebar-search-wrapper .search-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted, #71717a);
    margin-right: 6px;
    flex-shrink: 0;
}

.sidebar-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color, #f4f4f5);
    font-size: 0.76rem;
    padding: 6px 0;
    min-width: 0;
    font-family: inherit;
}

.sidebar-search-clear {
    background: transparent;
    border: none;
    color: var(--text-muted, #71717a);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.sidebar-search-clear:hover {
    color: #fff;
}

/* ── Encabezado de Grupos de Fecha ── */
.sidebar-date-group-header {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #71717a);
    padding: 0.5rem 0.35rem 0.2rem;
    font-family: var(--mono, monospace);
    list-style: none;
}

.session-title-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.session-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.66rem;
    flex-wrap: wrap;
}

.session-model-badge {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(10, 132, 255, 0.12);
    border: 1px solid rgba(10, 132, 255, 0.25);
    color: var(--accent-color, #0a84ff);
    font-size: 0.6rem;
    font-family: var(--mono, monospace);
    font-weight: 600;
    white-space: nowrap;
}

.session-actions-group {
    display: none;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 6px;
}

.sidebar-session-item:hover .session-actions-group,
.sidebar-session-item.active .session-actions-group {
    display: flex;
}

.session-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #a1a1aa);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.session-action-btn .y2k-icon-inline {
    width: 13px;
    height: 13px;
}

.session-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.session-action-btn.del-btn:hover {
    background: rgba(255, 69, 58, 0.15);
    color: #ff453a;
}

/* Formulario de Renombrado en Línea */
.session-rename-form {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.session-rename-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--accent-color, #0a84ff);
    border-radius: 6px;
    color: #fff;
    font-size: 0.78rem;
    padding: 4px 8px;
    outline: none;
    font-family: inherit;
}

.session-rename-actions {
    display: flex;
    align-items: center;
    gap: 3px;
}

.rename-confirm-btn, .rename-cancel-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 3px 6px;
    font-weight: bold;
}

.rename-confirm-btn {
    color: #30d158;
    border-color: rgba(48, 209, 88, 0.4);
    background: rgba(48, 209, 88, 0.12);
}

.rename-confirm-btn:hover {
    background: rgba(48, 209, 88, 0.25);
}

.rename-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.session-del-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #71717a);
    opacity: 0.4;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.sidebar-session-item:hover .session-del-btn {
    opacity: 1;
}

.session-del-btn:hover {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.12);
}

.sidebar-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 2.5rem 1rem;
    color: var(--text-muted, #71717a);
    text-align: center;
    font-size: 0.8rem;
}

.sidebar-empty-state .y2k-icon {
    font-size: 1.8rem;
    opacity: 0.5;
}

/* ── Footer del Sidebar ── */
.sidebar-footer {
    padding: 0.9rem 1.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.sidebar-storage-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.storage-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-color, #e4e4e7);
    font-family: var(--mono, monospace);
}

.storage-led {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #30d158;
    box-shadow: 0 0 6px rgba(48, 209, 88, 0.8);
}

.storage-sub {
    font-size: 0.68rem;
    color: var(--text-muted, #71717a);
    font-family: var(--mono, monospace);
}

.sidebar-footer-buttons {
    display: flex;
    gap: 8px;
}

.sidebar-footer-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color, #d4d4d8);
    font-size: 0.74rem;
    font-family: var(--mono, monospace);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-footer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-footer-btn.danger:hover {
    background: rgba(255, 69, 58, 0.15);
    border-color: rgba(255, 69, 58, 0.4);
    color: #ff453a;
}

/* =============================================================================
   ADAPTACIONES TRI-THEME
   ============================================================================= */

/* ── Tema Claro (Scandinavian) ── */
[data-theme="light"] .sidebar-drawer {
    background: #fdfcfb;
    border-right-color: rgba(44, 82, 52, 0.15);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    border-radius: 0px !important;
}

[data-theme="light"] .sidebar-header {
    border-bottom-color: rgba(44, 82, 52, 0.1);
    background: #ffffff;
}

[data-theme="light"] .sidebar-brand {
    color: #2c5234;
}

[data-theme="light"] .sidebar-primary-btn {
    border-radius: 0px !important;
    background: #2c5234;
    border-color: #2c5234;
    color: #ffffff;
    box-shadow: none;
}

[data-theme="light"] .sidebar-primary-btn:hover {
    background: #1e3a24;
}

[data-theme="light"] .sidebar-session-item {
    border-radius: 0px !important;
    background: #ffffff;
    border-color: rgba(44, 82, 52, 0.08);
}

[data-theme="light"] .sidebar-session-item:hover {
    background: #f6f5f3;
    border-color: rgba(44, 82, 52, 0.2);
}

[data-theme="light"] .sidebar-session-item.active {
    background: #eef3ed;
    border-color: #2c5234;
}

[data-theme="light"] .sidebar-session-item.active .session-title {
    color: #2c5234;
}

[data-theme="light"] .sidebar-footer {
    border-top-color: rgba(44, 82, 52, 0.1);
    background: #ffffff;
}

[data-theme="light"] .sidebar-footer-btn {
    border-radius: 0px !important;
    border-color: rgba(44, 82, 52, 0.2);
    background: #f6f5f3;
    color: #2c3539;
}

[data-theme="light"] .sidebar-search-wrapper,
[data-theme="light"] .sidebar-search-input,
[data-theme="light"] .session-model-badge,
[data-theme="light"] .session-action-btn,
[data-theme="light"] .session-rename-input,
[data-theme="light"] .rename-confirm-btn,
[data-theme="light"] .rename-cancel-btn {
    border-radius: 0px !important;
}

[data-theme="light"] .sidebar-search-wrapper {
    background: #ffffff;
    border-color: rgba(44, 82, 52, 0.2);
}

[data-theme="light"] .sidebar-search-wrapper:focus-within {
    border-color: #2c5234;
    box-shadow: none;
}

[data-theme="light"] .sidebar-search-input {
    color: #2c3539;
}

[data-theme="light"] .session-model-badge {
    background: rgba(44, 82, 52, 0.08);
    border-color: rgba(44, 82, 52, 0.25);
    color: #2c5234;
}

[data-theme="light"] .session-action-btn:hover {
    background: rgba(44, 82, 52, 0.1);
    color: #2c5234;
}

/* ── Tema Zen (E-Ink Technical) ── */
[data-theme="zen"] .sidebar-drawer {
    background: #141313;
    border-right: 1px solid #2d2c2c;
    box-shadow: none;
}

[data-theme="zen"] .sidebar-header {
    border-bottom: 1px solid #2d2c2c;
    background: #181717;
}

[data-theme="zen"] .sidebar-primary-btn {
    background: #201f1f;
    border: 1px solid #484740;
    color: #e5e2e1;
    box-shadow: none;
}

[data-theme="zen"] .sidebar-primary-btn:hover {
    background: #272626;
    border-color: #7a8c85;
}

[data-theme="zen"] .sidebar-session-item.active {
    background: #1e1d1d;
    border-color: #7a8c85;
}

[data-theme="zen"] .sidebar-search-wrapper {
    background: #1a1919;
    border-color: #2d2c2c;
    border-radius: 4px;
}

[data-theme="zen"] .sidebar-search-wrapper:focus-within {
    border-color: #7a8c85;
}

[data-theme="zen"] .session-model-badge {
    background: rgba(122, 140, 133, 0.15);
    border-color: rgba(122, 140, 133, 0.35);
    color: #7a8c85;
}

[data-theme="zen"] .session-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e2e1;
}
