/* --- VARIABLES CSS (Théming) --- */
:root {
    /* Palette Light Mode */
    --bg-body: #F2F4F7;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F9FAFB;
    --bg-chat-bubble: #F2F4F7;
    --border-color: #E4E7EC;
    --text-primary: #101828;
    --text-secondary: #667085;
    --accent-primary: #111111;
    --accent-brand: #6366F1; /* Indigo */
    --accent-brand-light: #EEF2FF;
    --success: #039855;
    --success-bg: #ECFDF3;
    --urgent: #D92D20;
    --urgent-bg: #FEF3F2;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --shadow: 0px 4px 6px -2px rgba(16, 24, 40, 0.03), 0px 12px 16px -4px rgba(16, 24, 40, 0.08);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-body: #0C111D;
    --bg-surface: #161B26;
    --bg-surface-hover: #1F242F;
    --bg-chat-bubble: #1F242F;
    --border-color: #2D3139;
    --text-primary: #F9FAFB;
    --text-secondary: #98A2B3;
    --accent-primary: #FFFFFF;
    --accent-brand: #818CF8;
    --accent-brand-light: rgba(99, 102, 241, 0.1);
    --shadow: none;
}

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; }
body { background-color: var(--bg-body); color: var(--text-primary); height: 100vh; display: flex; overflow: hidden; font-size: 15px; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* --- SIDEBAR --- */
.sidebar { width: 80px; background-color: var(--bg-surface); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; padding: 24px 0; z-index: 10; flex-shrink: 0; }
.logo { width: 48px; height: 48px; background: var(--accent-brand); color: white; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; margin-bottom: 40px; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.nav-links { display: flex; flex-direction: column; gap: 16px; width: 100%; align-items: center; }
.nav-item { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--text-secondary); font-size: 24px; transition: all 0.2s; position: relative; }
.nav-item:hover { background-color: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active { background-color: var(--accent-brand-light); color: var(--accent-brand); }
.nav-item.active::after { content: ''; position: absolute; right: -16px; top: 50%; transform: translateY(-50%); width: 4px; height: 24px; background: var(--accent-brand); border-radius: 4px 0 0 4px; }
.settings-area { margin-top: auto; display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* --- MAIN CONTENT --- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.header { height: 80px; padding: 0 40px; display: flex; align-items: center; justify-content: space-between; background: var(--bg-body); flex-shrink: 0; }
.breadcrumbs { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.breadcrumbs span { color: var(--text-primary); }
.header-actions { display: flex; gap: 20px; align-items: center; }
.theme-toggle { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-surface); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; color: var(--text-primary); }
.profile-btn { display: flex; align-items: center; gap: 12px; padding: 6px 12px 6px 6px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 50px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.username { font-weight: 600; font-size: 14px; margin-right: 4px; }

/* --- DASHBOARD GRID --- */
.content-scroll { padding: 0 40px 40px 40px; overflow-y: auto; height: 100%; }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px; }
.dashboard-title h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.5px; }
.dashboard-title p { color: var(--text-secondary); margin-top: 4px; }
.grid-container { display: grid; grid-template-columns: 2.5fr 1.5fr; gap: 24px; }
.card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-title { font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; background: var(--bg-body); color: var(--text-secondary); }

/* --- COMPONENTS --- */
/* Timeline */
.timeline-container { position: relative; padding-left: 20px; }
.timeline-line { position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; background: var(--border-color); z-index: 0; }
.course-item { position: relative; margin-bottom: 24px; z-index: 1; }
.course-dot { position: absolute; left: -21px; top: 20px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg-surface); border: 3px solid var(--text-secondary); }
.course-item.active .course-dot { border-color: var(--accent-brand); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); }
.course-item.finished .course-dot { border-color: var(--success); background: var(--success); }
.course-card { display: flex; background: var(--bg-surface-hover); border-radius: 12px; padding: 16px; border: 1px solid transparent; cursor: pointer; }
.course-item.active .course-card { background: var(--bg-surface); border-color: var(--accent-brand); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1); }
.time-box { display: flex; flex-direction: column; justify-content: center; padding-right: 16px; border-right: 1px solid var(--border-color); margin-right: 16px; min-width: 70px; text-align: right; }
.start-time { font-weight: 700; font-size: 16px; }
.end-time { font-size: 13px; color: var(--text-secondary); }

/* Tasks */
.task-input-area { display: flex; gap: 10px; margin-bottom: 20px; }
.task-input { flex: 1; background: var(--bg-body); border: none; padding: 12px 16px; border-radius: var(--radius-sm); outline: none; color: var(--text-primary); }
.add-btn { background: var(--accent-primary); color: var(--bg-surface); width: 40px; border-radius: var(--radius-sm); font-size: 20px; }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; transition: 0.2s; }
.task-row:hover { background: var(--bg-surface-hover); }
.checkbox { width: 20px; height: 20px; border: 2px solid var(--border-color); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.task-row.checked .checkbox { background: var(--success); border-color: var(--success); }
.task-row.checked .checkbox::after { content: '✔'; color: white; font-size: 12px; }
.task-row.checked span { text-decoration: line-through; color: var(--text-secondary); }

/* --- PAGE SPECIFIC: MESSAGERIE --- */
.messages-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; height: calc(100vh - 180px); }
.msg-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 8px; }
.msg-preview { padding: 16px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.msg-preview:hover { background: var(--bg-surface-hover); }
.msg-preview.active { background: var(--bg-surface); border-color: var(--accent-brand); box-shadow: var(--shadow); }
.chat-window { background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border-color); display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 16px; border-bottom: 1px solid var(--border-color); font-weight: 600; }
.chat-body { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.bubble { max-width: 70%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.bubble.received { background: var(--bg-chat-bubble); align-self: flex-start; border-bottom-left-radius: 2px; }
.bubble.sent { background: var(--accent-brand); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-input { padding: 16px; border-top: 1px solid var(--border-color); display: flex; gap: 10px; }
.chat-input input { flex: 1; border: 1px solid var(--border-color); padding: 10px 16px; border-radius: 20px; outline: none; background: var(--bg-body); color: var(--text-primary); }

/* --- PAGE SPECIFIC: NOTES --- */
.grades-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.grades-table th { text-align: left; color: var(--text-secondary); font-weight: 500; padding: 12px 16px; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.grades-table td { padding: 16px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.grade-badge { display: inline-block; padding: 4px 12px; border-radius: 6px; font-weight: 700; font-size: 13px; }
.grade-high { background: var(--success-bg); color: var(--success); }
.grade-mid { background: #FFFAEB; color: #B54708; } /* Warning color */
.grade-low { background: var(--urgent-bg); color: var(--urgent); }

/* Responsive */
@media (max-width: 1024px) {
    .grid-container { grid-template-columns: 1fr; }
    .header { padding: 0 20px; }
    .content-scroll { padding: 0 20px 20px 20px; }
    .sidebar { display: none; }
    .messages-layout { grid-template-columns: 1fr; }
    .msg-list { display: none; } /* Simplified for mobile */
}

/* --- AI ASSISTANT STYLES --- */

/* Bouton Flottant (FAB) */
.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--text-primary); /* Noir/Blanc selon thème */
    color: var(--bg-surface);
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}
.ai-fab:hover { transform: scale(1.1) rotate(15deg); }

/* Le Panneau Latéral */
.ai-panel {
    position: fixed;
    top: 0; right: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 40px rgba(0,0,0,0.1);
    z-index: 999;
    transform: translateX(110%); /* Caché à droite */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
}

.ai-panel.open { transform: translateX(0); }

/* Header IA */
.ai-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-surface-hover);
}
.ai-title { display: flex; align-items: center; gap: 12px; }
.ai-title h3 { font-size: 16px; font-weight: 700; }

/* Zone Chat */
.ai-chat-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 16px;
    background: var(--bg-body);
}

/* Bulles */
.ai-bubble {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    animation: popIn 0.3s ease;
}
.ai-bot {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 12px 2px;
    align-self: flex-start;
    color: var(--text-primary);
}
.ai-user {
    background: var(--text-primary);
    color: var(--bg-surface);
    border-radius: 12px 12px 2px 12px;
    align-self: flex-end;
}

/* Suggestions Chips */
.ai-suggestions {
    display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.ai-suggestions button {
    background: var(--bg-surface);
    border: 1px solid var(--accent-brand);
    color: var(--accent-brand);
    padding: 6px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    transition: 0.2s;
}
.ai-suggestions button:hover { background: var(--accent-brand); color: white; }

/* Input Zone */
.ai-input-zone {
    padding: 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex; gap: 10px;
}
.ai-input-zone input {
    flex: 1; padding: 12px; border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-body); color: var(--text-primary); outline: none;
}
.ai-input-zone button {
    width: 40px; background: var(--accent-brand); color: white;
    border-radius: 8px; font-size: 18px;
}

/* Animation Bouncing Dots (Typing) */
.typing-indicator { display: flex; gap: 4px; padding: 10px; align-self: flex-start; }
.dot { width: 6px; height: 6px; background: var(--text-secondary); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile */
@media (max-width: 768px) {
    .ai-panel { width: 100%; }
}