/* ==========================================================================
   THE TIME REVERSAL - MATERIAL 'ANDROID' APP THEME
   ========================================================================== */

/* --- 1. CORE VARIABLES (Material Color Palette) --- */
:root {
    --app-bg: #F0F4F8; /* Light grayish-blue app background */
    --surface: #FFFFFF; /* Pure white for cards */
    --primary: #1A73E8; /* Android/Google Blue */
    --primary-hover: #1557B0;
    --text-main: #202124;
    --text-muted: #5F6368;
    --border-color: #E8EAED;
    
    /* Android Geometry */
    --radius-card: 24px;
    --radius-btn: 50px; /* Pill shape */
    
    /* Layered Shadows */
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-hover: 0 12px 32px rgba(26, 115, 232, 0.15);
}

/* --- 2. GLOBAL RESET & ANIMATIONS --- */
* {
    box-sizing: border-box;
    font-family: 'Inter', 'Roboto', 'Segoe UI', sans-serif;
}

body {
    margin: 0;
    background-color: var(--app-bg);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* The "App Open" Cascade Animation */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 3. APP BAR (Sticky Header with Glassmorphism) --- */
header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px); /* Frosted glass effect */
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 15px 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 20px;
}

.logo-container img {
    height: 50px;
    margin-right: 15px;
}

.title-container h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--primary);
}

.tagline {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- 4. LANGUAGE SWITCHER (Segmented Control) --- */
.lang-switcher {
    position: absolute;
    right: 20px;
    background: var(--app-bg);
    padding: 4px;
    border-radius: var(--radius-btn);
    display: flex;
    gap: 2px;
}

.lang-btn {
    text-decoration: none;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-btn);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* --- 5. TOP NAVIGATION ICONS --- */
.top-icon-row {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin: 30px 0;
    animation: slideUpFade 0.6s ease-out backwards;
    animation-delay: 0.1s;
}

.img-icon-link img {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background: var(--surface);
    padding: 8px;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.img-icon-link:hover img {
    transform: scale(1.15) translateY(-5px);
}

/* --- 6. MAIN APP LAYOUT (Grid System) --- */
.main-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 50px;
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 30px;
    align-items: start;
}

/* --- 7. CARDS & SURFACES (Android Style) --- */
/* (REMOVED .tool-card from this generic list) */
.sidebar-box, .scoop-container, .article-card, .level-container {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Override padding for level-container so header touches edges */
.level-container { padding: 0; }

/* Apply staggered animations to layout columns */
.sidebar-box { animation: slideUpFade 0.6s ease-out backwards; animation-delay: 0.2s; }
.journal-entry { animation: slideUpFade 0.6s ease-out backwards; animation-delay: 0.3s; }
.right-sidebar { animation: slideUpFade 0.6s ease-out backwards; animation-delay: 0.4s; }

/* Interactive Hover States */
.article-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

.sidebar-title {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--primary);
    border-bottom: 2px solid var(--app-bg);
    padding-bottom: 10px;
}

/* --- 8. BUTTONS (Pill Shapes) --- */
.btn, .level-btn {
    display: inline-block;
    background: var(--app-bg);
    color: var(--primary);
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    text-align: center;
    width: max-content;
    margin-top: 10px;
}

.btn:hover, .level-btn:hover {
    background: var(--primary);
    color: var(--surface);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

/* --- 8.5 SLEEK INTERACTIVE TOOLS (SIDEBAR) --- */
.tool-card {
    background: var(--surface); 
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color); 
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-left: 4px solid transparent; 
}

.tool-card:hover {
    border-color: transparent;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px); 
}

.tool-card h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: color 0.2s;
}

.tool-card:hover h4 {
    color: var(--primary);
}

.tool-card p {
    font-size: 0.82rem; 
    margin: 0 0 12px 0;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Transform the big bulky button into a sleek text link */
/* Transform the big bulky button into a sleek text link */
.tool-card .btn {
    display: inline-block;
    background: transparent;
    color: var(--primary);
    padding: 0;
    box-shadow: none;
    text-decoration: none;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 0.75rem; /* Slightly smaller to balance the bold caps */
    font-weight: 800; /* Extra bold */
    letter-spacing: 1px; /* Spaced out for a technical look */
    text-transform: uppercase; /* Forces all caps */
    margin-top: 8px;
    transition: color 0.2s ease;
}

.tool-card .btn::after {
    content: " \2192"; 
    display: inline-block;
    margin-left: 6px;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); /* Smoother arrow slide */
}

.tool-card .btn:hover {
    background: transparent;
    color: var(--primary-hover);
    box-shadow: none;
}

.tool-card:hover .btn::after {
    transform: translateX(5px); /* Arrow shoots forward when the card is hovered */
}

/* ==========================================================================
   --- 9. HIGH SCHOOL DYNAMIC TABS (CLEAN APP THEME) --- 
   ========================================================================== */

.curriculum-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-top: 20px;
}

.level-container {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.level-header {
    padding: 20px 25px;
    color: white;
}
.level-header h3 { margin: 0 0 5px 0; font-size: 1.4rem; }
.level-header span { font-size: 0.85rem; opacity: 0.9; }

.tcs-bg { background: linear-gradient(135deg, #1A73E8, #4285F4); }
.bac1-bg { background: linear-gradient(135deg, #00B4DB, #0083B0); }
.bac2-bg { background: linear-gradient(135deg, #8E2DE2, #4A00E0); }

/* Zone de contenu flexible sans hauteur fixe */
.dynamic-tabs-content {
    padding: 25px;
    background-color: var(--surface);
    position: relative;
}

/* Par défaut, on cache complètement les panneaux inactifs pour éviter les superpositions transparentes */
.tab-panel {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Le panneau actif s'affiche proprement et s'agrandit */
.tab-panel.active-panel {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.panel-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--app-bg);
}

/* Style des nouvelles sous-sections (Annuelle / Mensuelle) */
.sub-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    margin: 15px 0 8px 0;
    padding-left: 5px;
}

/* Barre de navigation basse (Style onglets Android) */
.stack-controls {
    display: flex;
    justify-content: space-around;
    background: #F8FAFC;
    border-top: 1px solid var(--border-color);
    padding: 5px 0;
}

.stack-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 12px 20px;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    flex-grow: 1;
    text-align: center;
}

.stack-btn:hover {
    color: var(--primary);
    background-color: rgba(26, 115, 232, 0.04);
}

/* Style de l'onglet actif */
.stack-btn.active-btn {
    color: var(--primary);
    border-bottom-color: var(--primary);
}



/* ==========================================================================
   --- 10. LISTS & EXPANDABLE LOGIC --- 
   ========================================================================== */

.course-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

.course-list li { 
    margin-bottom: 8px; 
    position: relative; 
}

/* Targets both standard links and popup buttons */
.course-list li a,
.course-list li button { 
    display: block; 
    width: 100%;
    text-align: left;
    text-decoration: none; 
    color: var(--text-main); 
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-weight: 600; /* Makes the text bolder and more professional */
    font-size: 0.95rem;
    padding: 10px 15px 10px 35px; /* 35px left padding leaves perfect room for the arrow */
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: pointer;
}

/* The Arrow */
.course-list li::before { 
    content: '→'; 
    position: absolute; 
    left: 10px; 
    top: 50%;
    transform: translateY(-50%); /* Perfectly centers the arrow vertically */
    color: var(--text-muted); /* Subdued grey by default */
    font-weight: bold; 
    font-size: 1.1rem;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none; /* Prevents the arrow from blocking your clicks */
    z-index: 2;
}

/* --- Premium Hover States --- */
.course-list li a:hover,
.course-list li button:hover { 
    color: var(--primary); 
    background-color: #F8FAFC; /* Adds a soft premium background */
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    border-color: var(--border-color); /* Adds a crisp outline */
    transform: translateX(4px); /* The whole block nudges right */
}

/* The arrow lights up and shoots forward! */
.course-list li:hover::before {
    color: var(--primary);
    transform: translate(6px, -50%); 
}

/* --- Expandable Logic --- */
/* Hide items from 5th onwards by default */
.course-list li:nth-child(n+5) {
    display: none;
    opacity: 0;
    transform: translateY(-10px);
}

/* Show items when list gets .expanded class */
.course-list.expanded li:nth-child(n+5) {
    display: block;
    animation: slideDownItem 0.4s ease forwards;
}

/* Cascade delay for new items */
.course-list.expanded li:nth-child(5) { animation-delay: 0.05s; }
.course-list.expanded li:nth-child(6) { animation-delay: 0.10s; }
.course-list.expanded li:nth-child(7) { animation-delay: 0.15s; }
.course-list.expanded li:nth-child(8) { animation-delay: 0.20s; }

@keyframes slideDownItem {
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   --- 11. CHATBOT WIDGET --- 
   ========================================================================== */
#chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#chat-bubble {
    width: 65px;
    height: 65px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
}

#chat-window {
    width: 360px;
    height: 550px;
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpFade 0.3s ease-out;
}

.chat-header {
    background: var(--primary);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h4 { margin: 0; font-size: 1.1rem; }

.chat-body {
    flex: 1;
    padding: 20px;
    background: #F8FAFC;
    overflow-y: auto;
}

.bot-msg, .user-msg {
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    margin-bottom: 12px;
    max-width: 85%;
    line-height: 1.4;
    animation: slideUpFade 0.3s ease;
}

.bot-msg {
    background: white;
    color: var(--text-main);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.user-msg {
    background: var(--primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-input-area {
    padding: 15px;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    background: var(--app-bg);
    outline: none;
    transition: border 0.3s;
}

#chat-input:focus { border-color: var(--primary); }

#chat-send {
    padding: 10px 20px;
    border-radius: var(--radius-btn);
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

#chat-send:hover { background: var(--primary-hover); }

#chat-suggestions {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    background: var(--surface);
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    border-top: 1px solid var(--border-color);
}

#chat-suggestions::-webkit-scrollbar { display: none; }

.chip {
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-btn);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.chip:hover {
    background: var(--app-bg);
    color: var(--primary);
    border-color: var(--primary);
}

/* Animation d'attente (Les petits points de suspension) */
.typing-dots {
    animation: typing 1.5s infinite;
}
@keyframes typing {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* ==========================================================================
   --- 12. FX & EXTRAS --- 
   ========================================================================== */

/* Floating Background Bubbles */
#bubble-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1; 
    pointer-events: none; 
    overflow: hidden;
}

.floating-bubble {
    position: absolute;
    bottom: -100px;
    background: rgba(26, 115, 232, 0.05); 
    border-radius: 50%;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-120vh) rotate(360deg); opacity: 0; }
}

/* Android Ripple Effect */
.btn, .level-btn, .chip, .stack-btn {
    position: relative;
    overflow: hidden; 
}

.ripple-effect {
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 50%;
    animation: animateRipple 0.6s linear;
}

@keyframes animateRipple {
    0% { width: 0; height: 0; opacity: 0.5; }
    100% { width: 300px; height: 300px; opacity: 0; }
}

/* --- DOCUMENT POPUP (MODAL) THEME --- */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(32, 33, 36, 0.6); /* Fond sombre atténué */
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.popup-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    box-shadow: 0 24px 64px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-header {
    background: #F8FAFC;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 800;
}

.popup-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s;
}

.popup-close-btn:hover { color: #d63031; }

.popup-body {
    padding: 30px 25px;
    overflow-y: auto;
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.7;
}

/* Animations CSS */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { transform: scale(0.9) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
