/* --- 1. CONFIGURATION --- */
:root {
    --sidebar-width: 280px;
    --list-width: 400px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* DARK MODE */
/* DARK MODE (Matching Admin) */
[data-theme="dark"] {
    --bg-body: #0F1115;
    --bg-panel: #1A1D23;
    --bg-sidebar: #0F1115;
    --bg-hover: #1E222A;
    --text-main: #FFFFFF;
    --text-muted: #A0A6B1;
    --border: #2A2F3A;
    --primary: #2BB0ED;
    --primary-light: rgba(43, 176, 237, 0.15);
    --accent: #2BB0ED;
    /* Sync with primary for consistency */
    --danger: #F472B6;
    --logo-bg: rgba(255, 255, 255, 0.03);
}

/* LIGHT MODE (High Contrast) */
[data-theme="light"] {
    --bg-body: #f0f4f8;
    --bg-panel: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #475569;
    --border: #cbd5e1;
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --accent: #0369a1;
    --danger: #dc2626;
    --logo-bg: rgba(0, 0, 0, 0.03);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbar Invisible */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    transition: background-color 0.3s, color 0.3s;
}

/* --- 2. SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 30;
    border-right: 1px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s;
}

.logo-box {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--logo-bg) 0%, transparent 100%);
}

.logo-img {
    height: 36px;
    background: transparent;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border);
}

.logo-text h1 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.nav-semesters {
    padding: 1.25rem 1rem;
    display: flex;
    gap: 8px;
}

.btn-sem {
    flex: 1;
    padding: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: 0.2s;
}

.btn-sem:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.btn-sem.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(43, 176, 237, 0.25);
}

.module-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.module-list::-webkit-scrollbar {
    width: 4px;
}

.module-list::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.2);
    border-radius: 4px;
}

.nav-item {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-weight: 500;
    border: 1px solid transparent;
    transition: 0.2s;
    min-height: 48px;
}

.nav-item i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.nav-item span {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
    word-wrap: break-word;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--border);
    font-weight: 700;
}

[data-theme="light"] .nav-item.active {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.theme-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: 0.2s;
    width: 100%;
}

.theme-switch:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    color: var(--primary);
}

.theme-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.theme-switch:hover .theme-label {
    color: var(--primary);
}

.theme-switch:hover i {
    color: var(--primary) !important;
}

.credits {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.4;
    font-weight: 500;
    opacity: 0.7;
}

.credits strong {
    color: var(--text-main);
    font-weight: 700;
}

.dev-link {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 700;
    transition: 0.2s;
}

.dev-link:hover {
    color: var(--primary);
}

/* --- 3. LIST PANEL --- */
.list-panel {
    width: var(--list-width);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
    position: relative;
}

.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-sidebar);
    padding: 10px 15px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}

.btn-sem-mob {
    padding: 6px 12px;
    background: var(--bg-panel);
    border-radius: 20px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-sem-mob.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#mobile-module-list {
    display: none;
    padding: 12px 15px;
    gap: 10px;
    overflow-x: auto;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.mob-mod-tag {
    display: inline-block;
    padding: 8px 18px;
    background: var(--bg-body);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 600;
    flex-shrink: 0;
}

.mob-mod-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(43, 176, 237, 0.3);
}

.top-bar {
    padding: 1rem 1.5rem 0.5rem 1.5rem;
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-container {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 35px 12px 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: 0.2s;
    font-weight: 500;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43, 176, 237, 0.2);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 14px;
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    padding: 5px;
}

.notif-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    color: var(--text-muted);
    transition: 0.2s;
}

.notif-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-panel);
    opacity: 0;
    transform: scale(0);
    transition: 0.3s;
}

.notif-badge.show {
    opacity: 1;
    transform: scale(1);
}

.header-info {
    padding: 1rem 1.5rem 0.5rem 1.5rem;
}

.breadcrumbs {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-info h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}

.sub-nav {
    display: flex;
    gap: 8px;
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-top: 15px;
    overflow-x: auto;
}

.tab-btn {
    padding: 8px 16px;
    white-space: nowrap;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.tab-btn:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
}

[data-theme="dark"] .tab-btn.active {
    background: rgba(43, 176, 237, 0.1);
    color: var(--primary);
    border-color: rgba(43, 176, 237, 0.2);
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-panel);
}

.chapter-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 1.5rem 0 0.8rem 0;
    padding-left: 10px;
    border-left: 4px solid var(--primary);
    letter-spacing: 0.5px;
}

.search-group-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    margin: 1.5rem 0 0.8rem 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.file-item {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: 0.2s;
}

.file-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.file-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

[data-theme="dark"] .file-item.active {
    background: rgba(43, 176, 237, 0.1);
}

.file-item.active .fname {
    color: var(--primary);
    font-weight: 800;
}

.fname {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.file-left {
    display: flex;
    align-items: center;
    gap: 14px;
    overflow: hidden;
    width: 100%;
}

.file-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    text-align: center;
    font-size: 1.3rem;
}

.file-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.file-path {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

/* --- 4. PREVIEW AREA --- */
.preview-area {
    flex: 1;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    position: relative;
}

.toolbar {
    height: 70px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.doc-meta h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-main);
}

.doc-meta span {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn {
    text-decoration: none;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-dl {
    background: var(--primary);
    color: white;
    border: 1px solid transparent;
}

.btn-dl:hover {
    background: #1d4ed8;
    opacity: 0.9;
}

.btn-view {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-view:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

#pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    background: #1e1e1e;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-icon-bg {
    width: 80px;
    height: 80px;
    background: var(--bg-panel);
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
    color: var(--primary);
}

/* --- 5. NOTIFICATION DRAWER --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.notif-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
    z-index: 950;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.notif-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
}

.drawer-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.drawer-close:hover {
    background: var(--danger);
    color: white;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: var(--bg-body);
}

.notif-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    transition: 0.2s;
    display: flex;
    gap: 15px;
}

/* --- 6. SKELETON LOADERS --- */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
}

[data-theme="dark"] .skeleton {
    background: #1e293b;
    background: linear-gradient(90deg, var(--bg-panel) 25%, var(--border) 50%, var(--bg-panel) 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.sk-nav-item {
    height: 48px;
    margin-bottom: 8px;
    border-radius: 10px;
    width: 100%;
}

.sk-title {
    height: 24px;
    width: 40%;
    margin: 20px 0 15px 0;
}

.sk-file {
    height: 60px;
    width: 100%;
    margin-bottom: 10px;
    border-radius: 12px;
}

/* --- 7. FOCUS MODE --- */
body.focus-mode .sidebar {
    display: none;
}

body.focus-mode .list-panel {
    display: none;
}

body.focus-mode .notif-btn#focus-btn {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

body.focus-mode .preview-area {
    width: 100%;
    flex: 1;
}

.notif-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.notif-card::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--border);
}

.notif-card.nt-info::before {
    background: var(--primary);
}

.notif-card.nt-warning::before {
    background: #fbbf24;
}

.notif-card.nt-danger::before {
    background: var(--danger);
}

.notif-icon-large {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nt-info .notif-icon-large {
    background: rgba(45, 212, 191, 0.1);
    color: var(--primary);
}

.nt-warning .notif-icon-large {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.nt-danger .notif-icon-large {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.notif-details {
    flex: 1;
}

.notif-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.n-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.n-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 4px;
}

.n-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    font-weight: 500;
}

/* --- STYLE NOUVELLE NOTIFICATION (Point Rouge) --- */
.notif-card.is-new {
    border-color: var(--primary);
    background: linear-gradient(to right, var(--bg-panel), var(--bg-hover));
}

.notif-card.is-new::after {
    content: '';
    position: absolute;
    top: 15px;
    right: 15px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--danger);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* RESPONSIVE */
.mobile-header {
    display: none;
}

.back-btn {
    display: none;
    font-size: 1.2rem;
    padding: 5px;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 15px;
}

@media (max-width: 850px) {
    .sidebar {
        display: none;
    }

    .list-panel {
        width: 100%;
    }

    .mobile-header {
        display: flex;
    }

    .mobile-sem-nav {
        display: flex;
        gap: 8px;
    }

    #mobile-module-list {
        display: flex;
    }

    .preview-area {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
    }

    .preview-area.active {
        transform: translateX(0);
    }

    .back-btn {
        display: block;
    }

    .btn span {
        display: none;
    }

    .notif-drawer {
        width: 85%;
    }
}

/* Version Link Styling */
.version-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
    opacity: 0.8;
}

.version-link:hover {
    color: var(--primary);
    text-decoration: underline;
    opacity: 1;
}