/* Session History Sidebar Styles for MECE Agent */

/* =====================================================
   Sidebar Container
   ===================================================== */

.sessions-sidebar {
    position: fixed;
    top: 0;
    left: -350px; /* Hidden by default */
    width: 350px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 9998;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sessions-sidebar.open {
    left: 0;
}

/* Prevent body scroll when sidebar open on mobile */
body.sidebar-open {
    overflow: hidden;
}


/* =====================================================
   Sidebar Header
   ===================================================== */

.sidebar-header {
    flex-shrink: 0; /* Don't shrink */
    padding: 20px;
    background: linear-gradient(135deg, #2E3440 0%, #3B4252 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-right: 50px; /* Space for close button */
}

.sidebar-header-top h2 {
    font-size: 18px;
    margin: 0;
    font-weight: 600;
}

.sidebar-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 8px 12px;
    line-height: 1;
    opacity: 0.8;
    transition: all 0.2s;
    border-radius: 6px;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}


/* =====================================================
   Search Input
   ===================================================== */

.sidebar-search {
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-search input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-search svg {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}


/* =====================================================
   Session List Container
   ===================================================== */

.session-list-container {
    flex: 1 1 auto;
    min-height: 0; /* Enable proper flex scrolling */
    max-height: 100%; /* Prevent growing beyond parent */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
}

/* Custom scrollbar */
.session-list-container::-webkit-scrollbar {
    width: 8px;
}

.session-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.session-list-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.session-list-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* =====================================================
   Date Groups
   ===================================================== */

.session-group {
    margin-bottom: 25px;
}

.session-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 5px;
}

.session-group-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.session-count {
    font-size: 12px;
    color: #999;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 10px;
}


/* =====================================================
   Session Items
   ===================================================== */

.session-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.session-item:hover {
    border-color: #A3BE8C;
    box-shadow: 0 2px 8px rgba(163, 190, 140, 0.2);
    transform: translateX(2px);
}

.session-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.session-item-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.session-item-delete {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
    margin-left: 8px;
}

.session-item-delete:hover {
    color: #BF616A;
}


/* =====================================================
   Session Metadata
   ===================================================== */

.session-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #666;
}

.session-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-files {
    display: flex;
    align-items: center;
    gap: 4px;
}


/* =====================================================
   Badges
   ===================================================== */

.session-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-full {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-exercises {
    background: #FFF3E0;
    color: #E65100;
}

.badge-expansion {
    background: #E3F2FD;
    color: #1565C0;
}

.badge-lectures {
    background: #F3E5F5;
    color: #6A1B9A;
}

.session-file-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.file-badge {
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-json {
    background: #BBDEFB;
    color: #0D47A1;
}

.badge-opml {
    background: #C8E6C9;
    color: #1B5E20;
}

.badge-txt {
    background: #FFE0B2;
    color: #E65100;
}

.badge-wav {
    background: #F8BBD0;
    color: #880E4F;
}


/* =====================================================
   Pagination Controls
   ===================================================== */

.session-pagination-wrapper {
    flex-shrink: 0; /* Don't shrink */
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 15px;
}

.pagination-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-page {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: #A3BE8C;
    color: white;
    border-color: #A3BE8C;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(163, 190, 140, 0.3);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-page svg {
    flex-shrink: 0;
}

.page-indicator {
    font-size: 13px;
    color: #666;
    text-align: center;
    font-weight: 500;
}


/* =====================================================
   Empty State
   ===================================================== */

.sessions-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.sessions-empty-state svg {
    opacity: 0.3;
    margin-bottom: 15px;
    color: #ccc;
}

.sessions-empty-state p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #666;
}

.sessions-empty-state small {
    font-size: 13px;
    color: #999;
}


/* =====================================================
   Loading State
   ===================================================== */

.sessions-loading {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.sessions-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #A3BE8C;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.sessions-loading p {
    font-size: 14px;
    color: #666;
}


/* =====================================================
   Error State
   ===================================================== */

.sessions-error {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.sessions-error svg {
    opacity: 0.3;
    margin-bottom: 15px;
    color: #BF616A;
}

.sessions-error p {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.btn-retry {
    background: #A3BE8C;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-retry:hover {
    background: #8fa877;
    transform: translateY(-1px);
}


/* =====================================================
   Toggle Button (in main UI)
   ===================================================== */

.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, #A3BE8C 0%, #EBCB8B 100%);
    color: #2E3440;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9997;
    transition: all 0.2s;
    display: none; /* Hidden until user logs in */
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn.visible {
    display: flex;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
}


/* =====================================================
   Toast Notifications
   ===================================================== */

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: bottom 0.3s ease;
}

.toast.show {
    bottom: 30px;
}

.toast-success {
    background: #A3BE8C;
    color: #2E3440;
}

.toast-error {
    background: #BF616A;
    color: white;
}


/* =====================================================
   Mobile Responsive
   ===================================================== */

@media (max-width: 768px) {
    .sessions-sidebar {
        width: 100%;
        left: -100%;
    }

    .sessions-sidebar.open {
        left: 0;
    }

    /* Overlay effect on mobile */
    .sessions-sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(46, 52, 64, 0.8);
        z-index: -1;
        opacity: 0;
        transition: opacity 0.3s;
        pointer-events: none;
    }

    .sessions-sidebar.open::before {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-toggle-btn {
        top: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
    }
}

@media (min-width: 769px) {
    /* Desktop: sidebar pushes content */
    body.sidebar-open .container {
        margin-left: 350px;
        transition: margin-left 0.3s ease;
    }

    .sidebar-toggle-btn {
        top: 20px;
        left: 20px;
    }
}


/* =====================================================
   Animations
   ===================================================== */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.session-item {
    animation: slideIn 0.2s ease;
}

.session-group-items .session-item:nth-child(1) { animation-delay: 0.05s; }
.session-group-items .session-item:nth-child(2) { animation-delay: 0.1s; }
.session-group-items .session-item:nth-child(3) { animation-delay: 0.15s; }
.session-group-items .session-item:nth-child(4) { animation-delay: 0.2s; }
.session-group-items .session-item:nth-child(5) { animation-delay: 0.25s; }
