/* ==========================================================================
   SCRIBE PDT: MASTER STYLESHEET (NHS & DEPT EDITION)
   Version: 2.8 (Complete Commercial Build)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. IMPORTS & FONTS
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --------------------------------------------------------------------------
   1. VARIABLES & THEME CONFIGURATION
   -------------------------------------------------------------------------- */
:root {
    /* --- Brand Palette (NHS Blue & Department Purple) --- */
    
    /* Primary: NHS Blue Standard (#005EB8) */
    --brand-primary: #005EB8; 
    --brand-primary-dark: #003087;
    --brand-primary-light: #e6f6ff; /* Very light blue for backgrounds */
    
    /* Secondary: Department Identity (#3A0083) */
    --brand-dept: #3A0083;
    --brand-dept-dark: #240052;
    --brand-dept-light: #f0e6fa; /* Light lavender for backgrounds */
    
    /* --- LEGACY COMPATIBILITY VARIABLES --- */
    /* These map old color names to the new palette to prevent breakage */
    --brand-teal: var(--brand-primary);
    --brand-teal-dark: var(--brand-primary-dark);
    --brand-teal-light: var(--brand-primary-light);
    --teal-primary: var(--brand-primary);
    
    --brand-purple: var(--brand-dept);
    --brand-purple-dark: var(--brand-dept-dark);
    --brand-purple-light: var(--brand-dept-light);
    
    /* --- Semantic Colors --- */
    --success: #009639; /* NHS Green */
    --success-bg: #d1fae5;
    
    --danger: #d5281b;  /* NHS Red */
    --danger-bg: #fee2e2;
    
    --warning: #ffb81c; /* NHS Warm Yellow */
    --warning-bg: #fffbeb;
    
    --info: #005EB8;    /* Aligned with Primary */
    --info-bg: #dbeafe;

    /* --- Layout & Text (Light Mode Default) --- */
    --bg-color: #ffffff; /* Pure white for clinical look */
    --bg-secondary: #f3f4f6; /* Subtle grey for section breaks */
    --card-bg: #ffffff;
    
    --text-color: #212b32; /* NHS Dark Grey/Black for high readability */
    --secondary-text-color: #4c6272; /* NHS Secondary Grey */
    
    --link-color: var(--brand-primary);
    --border-color: #e8edee; /* Clean, light border */
    --input-bg: #ffffff;
    
    /* --- Professional Shadows (Layered) --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 94, 184, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(58, 0, 131, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --border-radius: 10px;
    --border-radius-sm: 6px;
    --transition-speed: 0.2s;
}

/* --- Dark Mode Override --- */
html.dark-mode {
    --bg-color: #0b1120; /* Deep slate, almost black */
    --bg-secondary: #161e31;
    --card-bg: #1e293b;
    
    --text-color: #f1f5f9;
    --secondary-text-color: #94a3b8;
    --border-color: #334155;
    --input-bg: #1e293b;

    /* Adjusted for visibility on dark backgrounds */
    --link-color: #38bdf8; /* Bright Sky Blue */
    
    --brand-primary: #38bdf8;  /* Lighter Blue */
    --brand-primary-dark: #0284c7;
    --brand-primary-light: rgba(56, 189, 248, 0.1);
    
    --brand-dept: #a78bfa; /* Light Violet (lighter version of #3A0083) */
    --brand-dept-dark: #7c3aed;
    --brand-dept-light: rgba(167, 139, 250, 0.1);
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 6px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 15px 30px rgba(0,0,0,0.5);
}

/* --- High Contrast Override --- */
html.high-contrast {
    --bg-color: #000000;
    --card-bg: #000000;
    --text-color: #FFFF00;
    --secondary-text-color: #FFFFFF;
    --link-color: #00FFFF;
    --border-color: #FFFFFF;
    --input-bg: #000000;
    
    --brand-primary: #00FFFF;
    --brand-primary-dark: #00CCCC;
    --brand-dept: #FF00FF; /* Magenta for Dept in high contrast */
    
    --success: #00FF00;
    --danger: #FF0000;
    --warning: #FFFF00;

    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
}

html.high-contrast body {
    color: var(--text-color) !important;
    background-color: var(--bg-color) !important;
}

/* --------------------------------------------------------------------------
   2. BASE TYPOGRAPHY & RESET
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5;
    font-size: 15px; /* Slightly increased for better readability */
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* Prevent horizontal scrolling globally */
    width: 100%;
    position: relative;
}

/* Custom Global Scrollbars for a Premium Feel */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}
html.dark-mode ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* Accessibility Focus States */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

/* Branding Headers */
h1, h2 {
    color: var(--brand-dept); 
}

html.dark-mode h1, html.dark-mode h2 {
    color: var(--text-color); /* White in dark mode for contrast */
}

p {
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
    font-weight: 500;
}

a:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: 0.9rem;
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   3. LAYOUT STRUCTURE
   -------------------------------------------------------------------------- */
.container {
    width: 94%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 15px;
}

.main-container {
    padding-top: 2rem;
    padding-bottom: 4rem;
    animation: fadeIn 0.5s ease-out;
    min-height: 85vh;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Navigation Bar (Clean White & Blue) --- */
.navbar {
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
    border-top: 4px solid var(--brand-primary); /* NHS Blue top stripe */
    width: 100%;
}

html.dark-mode .navbar {
    background-color: rgba(30, 41, 59, 0.95);
    border-top: 4px solid var(--brand-primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

.logo {
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--brand-dept); /* Department Purple Logo Text */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--brand-primary); /* NHS Blue Accent in Logo */
    font-weight: 600;
    margin-left: 4px;
}

.nav-links {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 0 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--secondary-text-color);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-speed) ease;
    padding: 0.5rem 0;
    position: relative;
}

.nav-links a:hover {
    color: var(--brand-primary);
    text-decoration: none;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background-color: var(--brand-primary);
    transition: width 0.3s ease;
}

.nav-links a:hover::after { width: 100%; }

.nav-links a.admin-link {
    color: var(--brand-dept);
}

.nav-right-items {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* --- Header Elements --- */
.nav-logout {
    background-color: white;
    color: var(--brand-primary) !important;
    border: 1px solid var(--brand-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-speed);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.nav-logout:hover {
    background-color: var(--brand-primary);
    color: white !important;
    text-decoration: none;
}

/* Avatar Initials (Small for Nav) */
.user-avatar-small {
    width: 32px; 
    height: 32px; 
    background: var(--brand-dept); /* Purple Background */
    color: white;
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700; 
    font-size: 0.8rem; 
    text-transform: uppercase;
}

/* Avatar Initials (Large for Dashboard Hero) */
.user-avatar-hero {
    width: 64px; 
    height: 64px; 
    background: var(--brand-dept); /* Purple Background */
    color: white;
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 1.8rem; 
    font-weight: 700; 
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md); 
    border: 4px solid white; 
    text-transform: uppercase;
}

.mode-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.8;
    transition: all var(--transition-speed) ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-toggle:hover {
    opacity: 1;
    background-color: var(--bg-secondary);
    color: var(--brand-primary);
}

/* --- Mobile Menu --- */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 24px;
    flex-direction: column;
    justify-content: space-between;
    z-index: 101;
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--brand-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-nav-menu {
    display: none;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    box-shadow: var(--shadow-lg);
    z-index: 99;
}

.mobile-nav-menu a {
    display: block;
    padding: 1rem;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-menu a:last-child {
    border-bottom: none;
}

.mobile-nav-menu .nav-logout {
    margin-top: 1rem;
    text-align: center;
    display: block;
}

@media (max-width: 900px) {
    .nav-links, .nav-right-items { display: none; }
    .mobile-menu-toggle { display: flex; }
    
    .navbar.menu-open .mobile-nav-menu { display: block; animation: slideDown 0.3s ease; }
    
    .navbar.menu-open .mobile-menu-toggle span:nth-child(1) { transform: rotate(45deg) translate(7px, 7px); }
    .navbar.menu-open .mobile-menu-toggle span:nth-child(2) { opacity: 0; }
    .navbar.menu-open .mobile-menu-toggle span:nth-child(3) { transform: rotate(-45deg) translate(7px, -7px); }
}

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

/* --- Footer --- */
.footer-modern {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding-top: 4rem;
    padding-bottom: 2rem;
    margin-top: 4rem;
    color: var(--text-color);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-col h4 {
    margin-bottom: 1rem;
    color: var(--brand-primary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-col p {
    color: var(--secondary-text-color);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-col ul li {
    margin-bottom: 0.5rem;
}

.footer-col ul li a {
    color: var(--secondary-text-color);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 0.9rem;
}

.footer-col ul li a:hover {
    color: var(--brand-primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--secondary-text-color);
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

/* --------------------------------------------------------------------------
   4. UI COMPONENTS (Buttons, Forms, Cards)
   -------------------------------------------------------------------------- */

/* --- Modern Buttons --- */
.btn, .enroll-btn, .certificate-btn, .btn-admin, .start-module-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-align: center;
    text-decoration: none !important;
    line-height: 1.5;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
}

.btn:hover, .enroll-btn:hover, .certificate-btn:hover, .btn-admin:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn-primary, .start-module-btn {
    background-color: var(--brand-primary) !important;
    border: 1px solid var(--brand-primary);
    color: white !important;
}

.btn-primary:hover, .start-module-btn:hover {
    background-color: var(--brand-primary-dark) !important;
    border-color: var(--brand-primary-dark);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-color) !important;
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: #cbd5e1;
}

.btn-danger {
    background-color: var(--danger);
    color: white !important;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

/* --- SUCCESS / REVIEW BUTTON (PURPLE) --- */
.btn-success {
    background-color: var(--brand-dept) !important;
    border: 1px solid var(--brand-dept) !important;
    color: white !important;
}

.btn-success:hover {
    background-color: var(--brand-dept-dark) !important;
    border-color: var(--brand-dept-dark) !important;
}

.btn-small {
    width: auto !important;
    padding: 0.4rem 0.9rem !important;
    font-size: 0.85rem !important;
}

/* --- Specialized Buttons --- */
.enroll-btn {
    background-color: transparent !important;
    border: 2px solid var(--brand-primary);
    color: var(--brand-primary) !important;
}

.enroll-btn:hover {
    background-color: var(--brand-primary) !important;
    color: white !important;
}

/* --- ENROLLED STATE (PURPLE) --- */
.enroll-btn.enrolled {
    border-color: var(--brand-dept); /* Purple Border */
    color: var(--brand-dept) !important; /* Purple Text */
    background-color: transparent !important;
}

.enroll-btn.enrolled:hover {
    background-color: var(--brand-dept-light) !important; /* Light Purple Background */
    border-color: var(--brand-dept-dark);
    color: var(--brand-dept-dark) !important;
}

.certificate-btn {
    background-color: var(--brand-dept); /* Purple */
    margin-top: 1rem;
    color: white !important;
}

/* --- Unenroll Icon Button --- */
.unenroll-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    padding: 0;
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    color: var(--danger);
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none; /* Don't catch clicks when hidden */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.module-card:hover .unenroll-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.unenroll-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: var(--danger);
}

/* --- Cards --- */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: box-shadow 0.3s ease;
}

/* --- Forms --- */
.auth-container {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
    margin: 4rem auto;
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

input[type="text"], input[type="email"], input[type="password"], 
input[type="number"], input[type="file"], select, textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: var(--border-radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 94, 184, 0.15);
}

/* Search Wrapper (Pill Style) */
.search-wrapper {
    position: relative;
    width: 100%;
}
.search-wrapper input {
    padding-left: 2.5rem;
    border-radius: 20px;
}
/* REMOVED: .search-wrapper::before to prevent double rendering of the magnifying glass emoji over modern SVGs */

button[type="submit"] {
    background-color: var(--brand-primary);
    color: white;
    width: 100%;
    padding: 0.85rem;
    border-radius: 8px;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

button[type="submit"]:hover {
    background-color: var(--brand-primary-dark);
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

/* --- Messages --- */
.message {
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.message.error {
    background-color: #fff5f5;
    color: #c53030;
    border-color: #feb2b2;
}

.message.success {
    background-color: #f0fff4;
    color: #166534;
    border-color: #86efac;
}

.message.info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* --- Empty States --- */
.empty-state {
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    color: var(--secondary-text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    grid-column: 1 / -1; /* Span full width in grids */
}
.empty-state-icon { font-size: 3rem; opacity: 0.5; margin-bottom: 0.5rem; }
.empty-state h3 { margin: 0; font-size: 1.1rem; color: var(--text-color); }
.empty-state p { margin: 0; font-size: 0.9rem; max-width: 400px; }


/* --------------------------------------------------------------------------
   5. DASHBOARD & CATALOGUE ELEMENTS
   -------------------------------------------------------------------------- */
/* --- Hero & Banner Styles --- */
.dashboard-header, .banner, .catalogue-hero {
    margin-bottom: 2.5rem;
    background-color: var(--brand-dept); /* Department Purple Background */
    color: white !important; /* Force White Text */
    padding: 2.5rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    background-image: linear-gradient(135deg, var(--brand-dept), var(--brand-dept-dark));
}

/* Ensure headers inside banners are always white */
.dashboard-header h1, .banner h1, .catalogue-hero h1,
.dashboard-header h2, .banner h2, .catalogue-hero h2,
.dashboard-header h3, .banner h3, .catalogue-hero h3 {
    color: white !important;
    border-bottom-color: rgba(255,255,255,0.3);
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
}

.dashboard-header p, .banner p, .catalogue-hero p {
    color: rgba(255,255,255,0.9) !important;
    font-size: 1.1rem;
    max-width: 700px;
    margin-bottom: 0;
}

/* --- Filter Toolbars --- */
.filter-toolbar, .dashboard-filters {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.filter-group { flex-grow: 1; min-width: 200px; }
.filter-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--secondary-text-color); }
.filter-group input, .filter-group select, .search-bar, .ward-filter { width: 100%; margin: 0; }

.filter-button {
    width: auto; padding: 0.8rem 1.5rem; background-color: var(--card-bg);
    border: 1px solid var(--border-color); color: var(--text-color);
    cursor: pointer; border-radius: var(--border-radius-sm);
}
.filter-button:hover {
    background-color: var(--bg-secondary); border-color: var(--brand-primary); color: var(--brand-primary);
}

/* --- View Tabs (Modules/Curriculums) --- */
.view-tabs {
    display: flex; gap: 0.5rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border-color);
    padding-bottom: 0; overflow-x: auto;
    max-width: 100%;
}

.view-tab-item {
    padding: 1rem 1.5rem; font-weight: 600; color: var(--secondary-text-color);
    text-decoration: none; border-bottom: 3px solid transparent;
    transition: all 0.2s; margin-bottom: -1px; white-space: nowrap;
    display: flex; align-items: center; gap: 0.5rem;
}

.view-tab-item:hover { color: var(--brand-primary); background: rgba(0,0,0,0.02); }
.view-tab-item.active {
    color: var(--brand-primary); border-bottom-color: var(--brand-primary);
    background: var(--brand-primary-light);
}

/* --- Stats Widgets --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: -3rem; /* Pull up into hero */
    margin-bottom: 3rem;
    position: relative;
    z-index: 10;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-xl); }

.stat-icon-wrapper {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0;
}
.stat-icon-teal { background: var(--brand-primary-light); color: var(--brand-primary); }
.stat-icon-purple { background: var(--brand-dept-light); color: var(--brand-dept); }
.stat-icon-red { background: var(--danger-bg); color: var(--danger); }
.stat-icon-orange { background: var(--warning-bg); color: var(--warning); }

.stat-content h4 {
    margin: 0; font-size: 0.8rem; color: var(--secondary-text-color);
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.stat-content .stat-value {
    font-size: 1.6rem; font-weight: 800; color: var(--text-color); line-height: 1.2;
}

/* --- Module Grid & Cards --- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    width: 100%;
}

.module-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border-color);
    height: 100%;
    min-height: 360px;
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-primary);
}

.module-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--border-color);
    background-color: #eee;
}

.module-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.module-card-content h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.15rem;
    color: var(--text-color);
}

.module-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.avg-stars {
    font-size: 1rem;
    display: flex;
    align-items: center;
    color: #f0ad4e;
}

.count-text {
    font-size: 0.85em;
    color: var(--secondary-text-color);
    margin-left: 0.4em;
}

.enroll-count {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    font-weight: 500;
    white-space: nowrap;
}

.description-area {
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.description-area p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    color: var(--secondary-text-color);
}

.toggle-desc-btn {
    background: none;
    border: none;
    color: var(--link-color);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    display: inline-block;
}

.full-description {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.card-actions {
    margin-top: auto;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* --- Rich Focus Card (Featured/Department Identity) --- */
.focus-card-rich {
    display: flex;
    flex-direction: row;
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
    min-height: 240px;
    overflow: hidden;
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
    /* Subtle purple branding at the top */
    border-top: 4px solid var(--brand-dept);
}

.focus-rich-image {
    width: 40%;
    position: relative;
    overflow: hidden;
    background-color: #f1f5f9;
}

.focus-rich-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    transition: transform 0.5s ease;
}

.focus-card-rich:hover .focus-rich-image img { transform: scale(1.05); }

.focus-rich-content {
    width: 60%;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.focus-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brand-dept);
    margin-bottom: 0.75rem;
    background: var(--brand-dept-light);
    padding: 4px 10px;
    border-radius: 6px;
    align-self: flex-start;
}

.focus-rich-content h3 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    line-height: 1.2;
}

.focus-rich-content p {
    font-size: 1rem;
    color: var(--secondary-text-color);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Fix button visibility on light mode */
.focus-actions .btn {
    background: var(--brand-primary);
    color: white !important;
    border: 1px solid var(--brand-primary);
    padding: 0.8rem 2rem;
}
.focus-actions .btn:hover {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
}

@media (max-width: 768px) {
    .focus-card-rich { flex-direction: column; }
    .focus-rich-image { width: 100%; height: 180px; }
    .focus-rich-content { width: 100%; padding: 1.5rem; }
    .focus-rich-content h3 { font-size: 1.4rem; }
}

/* --- Category Badges --- */
.category-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--brand-primary-dark);
    background-color: var(--brand-primary-light);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    align-self: flex-start;
}

html.dark-mode .category-badge {
    color: #80cbc4;
    background-color: rgba(128, 203, 196, 0.15);
}

/* --- Completed State & Unenroll --- */
.completed-card {
    filter: grayscale(20%);
    opacity: 0.9;
}

.completed-card:hover {
    filter: grayscale(0);
    opacity: 1;
}

.completed-card .start-module-btn {
    background-color: var(--brand-dept) !important;
    border-color: var(--brand-dept);
}

.completed-card:hover .start-module-btn {
    background-color: var(--brand-dept-dark) !important;
}

/* Curriculum Meta (Inside Card) */
.curriculum-meta {
    font-size: 0.9rem; font-weight: 600; color: var(--secondary-text-color);
    padding: 0.75rem; background: var(--bg-secondary); border-radius: 8px;
    margin-bottom: 1rem; text-align: center;
}

/* Curriculum Enroll Button */
.btn-curriculum-enroll {
    display: block; width: 100%; box-sizing: border-box; text-align: center;
    background: var(--brand-primary); color: white !important; text-decoration: none !important;
    padding: 0.8rem; border-radius: 8px; font-weight: 700; transition: all 0.2s; border: none;
}
.btn-curriculum-enroll:hover { background: var(--brand-primary-dark); transform: translateY(-1px); }
.btn-curriculum-enroll.enrolled { background: var(--brand-dept); }
.btn-curriculum-enroll.enrolled:hover { background: var(--brand-dept-dark); }

/* Sort Options */
.sort-options { margin-bottom: 1.5rem; font-size: 0.9rem; color: var(--secondary-text-color); display: flex; gap: 1rem; align-items: center; }
.sort-options strong { color: var(--text-color); }
.sort-pill { 
    padding: 0.4rem 1rem; border-radius: 20px; background: var(--bg-color);
    border: 1px solid var(--border-color); color: var(--secondary-text-color);
    text-decoration: none; transition: all 0.2s; 
}
.sort-pill:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.sort-pill[data-active="true"] { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }

/* --- Locked / Prereq --- */
.module-card.locked { opacity: 0.7; }
.module-card.locked img { filter: grayscale(80%); }
.module-card.locked .enroll-btn { background-color: var(--secondary-text-color); cursor: not-allowed; opacity: 0.7; }
.lock-overlay {
    position: absolute; top: 10px; right: 10px; background-color: rgba(0, 0, 0, 0.6);
    color: white; border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    z-index: 5; pointer-events: none; font-size: 1rem;
}
.prerequisites-list {
    display: block; margin-top: 0.5rem; padding: 0.75rem; background: #fff3cd;
    color: #856404; border-radius: 6px; font-size: 0.85rem; border: 1px solid #ffeeba;
}

/* --------------------------------------------------------------------------
   6. LEARNING CONTENT & LESSON VIEW (FIXED MEDIA)
   -------------------------------------------------------------------------- */
.content-page {
    max-width: 850px;
    margin: 2rem auto;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 3rem;
    border: 1px solid var(--border-color);
}

.lesson-content {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-color);
}

.lesson-content h3 {
    font-size: 1.4rem;
    color: var(--brand-dept);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}

/* --- Content Media Handling --- */
.lesson-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.lesson-content video,
.lesson-content iframe {
    display: block;
    width: 100%; 
    max-width: 800px; /* Cap width so it isn't massive on desktops */
    height: auto;
    margin: 2.5rem auto; /* Spacing and Centering */
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    clear: both; /* Force text to sit above/below, never beside */
    border: none;
}

.lesson-content iframe {
    aspect-ratio: 16 / 9;
}

/* Legacy video container support */
.video-container-responsive {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 0;
    padding-top: 56.25%;
    margin: 2rem auto;
    border-radius: 12px;
    background-color: #000;
    box-shadow: var(--shadow-md);
    display: block;
    clear: both;
    overflow: hidden;
}

.video-container-responsive iframe {
    position: absolute;
    top: 0; left: 0; width: 100% !important; height: 100% !important; margin: 0 !important; border: none; aspect-ratio: auto;
}

/* --- Content Boxes --- */
.info-box, .warning-box, .success-box {
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: 6px;
    font-weight: 500;
    display: block;
    font-size: 0.95rem;
}

.info-box { background: var(--info-bg); border-left: 5px solid var(--info); color: #003087; }
.warning-box { background: var(--warning-bg); border-left: 5px solid var(--warning); color: #78350f; }
.success-box { background: var(--success-bg); border-left: 5px solid var(--success); color: #064e3b; }

html.dark-mode .info-box { background: rgba(59, 130, 246, 0.2); color: #90caf9; }
html.dark-mode .warning-box { background: rgba(245, 158, 11, 0.2); color: #ffcc80; }
html.dark-mode .success-box { background: rgba(16, 185, 129, 0.2); color: #a5d6a7; }

/* --- Dividers & Tables --- */
.lesson-content hr { border: 0; height: 1px; background: var(--border-color); margin: 2.5rem 0; }
.lesson-content blockquote { border-left: 4px solid var(--brand-primary); margin: 1.5rem 0; padding-left: 1.25rem; font-style: italic; color: var(--secondary-text-color); font-size: 1.1rem; }
.lesson-content table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.9rem; }
.lesson-content th, .lesson-content td { padding: 0.7rem; border: 1px solid var(--border-color); text-align: left; }
.lesson-content th { background: var(--bg-secondary); font-weight: 700; color: var(--brand-primary); }

/* --- Interactive Images (Hotspots) --- */
.interactive-image-container {
    position: relative;
    display: block;
    max-width: 100%;
    margin: 2rem auto;
}

.interactive-image-container img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    margin: 0;
}

.hotspot {
    position: absolute;
    cursor: pointer;
    z-index: 10;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    border-radius: 50%;
    transition: background 0.2s;
}

.hotspot:hover { background: rgba(255, 255, 255, 0.6); }

.hotspot-info {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    width: max-content;
    max-width: 250px;
}

.hotspot:hover + .hotspot-info { opacity: 1; }

/* --- Lesson Navigation --- */
.lesson-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.lesson-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--brand-primary) !important;
    color: #ffffff !important;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none !important;
    border: none;
    font-size: 0.95rem;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: var(--shadow-sm);
}

.lesson-nav-btn:hover { background-color: var(--brand-primary-dark) !important; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.lesson-nav-btn.disabled { background-color: var(--secondary-text-color) !important; opacity: 0.6; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.lesson-nav-btn.complete-btn { background-color: var(--brand-dept) !important; }
.lesson-nav-btn.complete-btn:hover { background-color: var(--brand-dept-dark) !important; }

/* --------------------------------------------------------------------------
   7. INTERACTIVE ELEMENTS (Accordions, Tabs)
   -------------------------------------------------------------------------- */
.lesson-accordion {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--card-bg);
    margin-top: 2rem;
}

.accordion-item { border-bottom: 1px solid var(--border-color); }

.accordion-header {
    width: 100%;
    background-color: var(--card-bg);
    border: none;
    padding: 1.1rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-align: left;
    color: var(--text-color);
    transition: background-color 0.2s;
}

.accordion-header:hover { background-color: var(--bg-secondary); }
.accordion-header.active { background-color: var(--brand-primary-light); color: var(--brand-primary-dark); }
.accordion-header.locked { opacity: 0.6; cursor: not-allowed; background-color: var(--bg-color); }

.accordion-content {
    padding: 0;
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: var(--bg-color);
}

.accordion-content-inner { padding: 1.25rem; border-top: 1px solid var(--border-color); }
.accordion-toggle { margin-left: auto; transition: transform 0.3s; }
.accordion-header.active .accordion-toggle { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   8. ADMIN CREATOR (Wizard & Dynamic Items)
   -------------------------------------------------------------------------- */
.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
    padding: 0 5px;
}

.step-indicator::before {
    content: '';
    position: absolute;
    top: 50%; left: 0; width: 100%; height: 2px;
    background: var(--border-color);
    z-index: 0;
    transform: translateY(-50%);
}

.step-tab {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    padding: 0.5rem 1.2rem;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-weight: 600;
    color: var(--secondary-text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.9rem;
}

.step-tab.active {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(0, 94, 184, 0.15);
}

.step-tab.completed { background: var(--brand-primary); border-color: var(--brand-primary); color: white; }

.step-number {
    width: 24px; height: 24px; background: var(--border-color); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}

.step-tab.active .step-number { background: var(--brand-primary); color: white; }
.step-tab.completed .step-number { background: white; color: var(--brand-primary); }

.dynamic-item {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.dynamic-item h4 {
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1rem;
    display: flex; justify-content: space-between; align-items: center;
}

.sticky-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 500;
}

.nav-btn-group { display: flex; gap: 1rem; }

/* Editor Toolbar */
.simple-editor-toolbar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 0.5rem;
    border-radius: 8px 8px 0 0;
    display: flex; gap: 0.5rem; flex-wrap: wrap;
}

.se-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}

.se-btn:hover { background: #e0e0e0; color: var(--brand-primary); border-color: var(--brand-primary); }

.simple-editor-textarea {
    border-radius: 0 0 8px 8px;
    min-height: 200px;
    font-family: monospace;
    line-height: 1.5;
    border-top: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   9. TIMELINE (Study Days)
   -------------------------------------------------------------------------- */
.timeline-container { display: flex; flex-direction: column; padding: 1rem 0; }

.timeline-item {
    display: grid;
    grid-template-columns: 70px 40px 1fr;
    gap: 1rem;
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:not(:last-child)::before {
    content: '';
    position: absolute; top: 18px; left: 89px; width: 2px; height: calc(100% - 10px);
    background-color: var(--border-color);
    z-index: 1;
}

.timeline-time {
    grid-column: 1; text-align: right; font-weight: 700; font-size: 0.95rem;
    padding-top: 8px; color: var(--text-color);
}

.timeline-time .end-time {
    font-weight: 400; font-size: 0.8rem; opacity: 0.7; display: block; margin-top: 0.2rem;
}

.timeline-connector {
    grid-column: 2; position: relative; z-index: 2; display: flex; justify-content: center;
}

.timeline-dot {
    width: 36px; height: 36px; border-radius: 50%;
    background-color: var(--card-bg); border: 2px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: var(--brand-dept); font-weight: 700;
    transition: all 0.2s;
}

.timeline-card {
    grid-column: 3; display: flex; align-items: center; gap: 1.25rem;
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); box-shadow: var(--shadow-sm);
    padding: 1.25rem; text-decoration: none; color: var(--text-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    z-index: 2; cursor: pointer;
}

.timeline-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.timeline-card-icon { flex-shrink: 0; font-size: 1.8rem; color: var(--brand-dept); opacity: 0.8; }
.timeline-card-content { flex-grow: 1; }
.timeline-card-content h3 { margin: 0 0 0.25rem 0; font-size: 1.1rem; font-weight: 700; color: var(--text-color); }
.timeline-card-content .duration { font-size: 0.85rem; color: var(--secondary-text-color); font-weight: 500; }
.timeline-card-action { flex-shrink: 0; font-size: 1.25rem; color: var(--secondary-text-color); transition: transform 0.2s; }
.timeline-card:hover .timeline-card-action { transform: translateX(4px); color: var(--brand-dept); }

.timeline-item.locked .timeline-dot { background-color: var(--bg-color); color: var(--secondary-text-color); border-color: var(--border-color); }
.timeline-item.locked .timeline-card { background-color: var(--bg-color); opacity: 0.6; cursor: not-allowed; filter: grayscale(80%); box-shadow: none; }
.timeline-item.locked .timeline-card:hover { transform: none; }
.timeline-item.completed .timeline-dot { border-color: var(--success); background-color: var(--success); color: white; }
.timeline-item.completed .timeline-card { border-left: 4px solid var(--success); }
.timeline-item.next-up .timeline-dot { border-color: var(--brand-dept); background-color: var(--brand-dept); color: white; animation: pulse 1.5s infinite; }
.timeline-item.next-up .timeline-card { border: 2px solid var(--brand-dept); box-shadow: 0 6px 15px rgba(58, 0, 131, 0.15); }

@keyframes pulse { 50% { opacity: 0.5; } }

/* --------------------------------------------------------------------------
   10. FORUMS & Q&A
   -------------------------------------------------------------------------- */
.forum-post {
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); padding: 1.5rem; margin-bottom: 1.5rem;
    position: relative; box-shadow: var(--shadow-sm);
}
.forum-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.75rem; font-size: 0.85rem; border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
}
.forum-meta .user { font-weight: 700; color: var(--brand-dept); font-size: 0.9rem; }
.forum-meta .date { color: var(--secondary-text-color); }
.forum-content { font-size: 1rem; line-height: 1.6; color: var(--text-color); white-space: pre-wrap; }
.forum-answers-container { margin-top: 1.5rem; padding-left: 1.5rem; position: relative; }
.forum-answers-container::before {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 2px;
    background-color: var(--border-color);
}
.forum-answer {
    background-color: #f9fdfa; border: 1px solid #86efac; border-left-width: 4px;
    border-left-color: #22c55e; border-radius: 0 8px 8px 8px; padding: 1rem;
    margin-bottom: 1rem; position: relative; box-shadow: var(--shadow-sm);
}
.forum-answer .forum-content { white-space: pre-wrap; font-size: 0.95rem; }
.admin-badge {
    display: inline-block; background-color: #22c55e; color: white; font-size: 0.7rem;
    text-transform: uppercase; font-weight: 800; padding: 0.2rem 0.5rem;
    border-radius: 12px; margin-left: 0.4rem; vertical-align: middle; letter-spacing: 0.5px;
}
html.dark-mode .forum-answer { background-color: #14532d; border-color: #15803d; border-left-color: #4ade80; }

/* --------------------------------------------------------------------------
   11. UTILITIES & ANIMATIONS
   -------------------------------------------------------------------------- */
/* Progress Bar (Striped) */
.progress-bar {
    width: 100%; background-color: var(--border-color); border-radius: 10px;
    overflow: hidden; height: 16px; margin: 1rem 0; position: relative;
}

.progress-bar-inner {
    height: 100%; background-color: var(--brand-primary); width: 0%;
    transition: width 0.8s ease-in-out; display: flex; align-items: center;
    justify-content: center; color: white; font-size: 0.7rem; font-weight: 700;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem; animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

/* Scroll to Top */
#scrollToTopBtn {
    display: none; position: fixed; bottom: 30px; right: 30px; z-index: 99;
    border: none; outline: none; background-color: var(--brand-primary); color: white;
    cursor: pointer; padding: 0; border-radius: 50%; width: 40px; height: 40px;
    font-size: 1.2rem; box-shadow: var(--shadow-md); transition: all 0.3s ease;
    opacity: 0; transform: translateY(20px);
}

#scrollToTopBtn.visible { opacity: 1; transform: translateY(0); }

/* Toasts */
#toast-container {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.8rem 1.2rem; border-radius: 8px; font-weight: 600;
    background: var(--card-bg); box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    opacity: 0; transform: translateY(20px); transition: all 0.3s ease;
    pointer-events: auto; color: white; font-size: 0.9rem;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background-color: var(--success); }
.toast.error { background-color: var(--danger); }
.toast.info { background-color: var(--info); }

/* ==========================================================================
   12. COMMUNITY & MESSAGE BOARD (Final Refined)
   ========================================================================== */

/* --- Forum Layout --- */
.forum-list { display: flex; flex-direction: column; gap: 1rem; }

.forum-post, .forum-answer {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
    position: relative;
}

.forum-post:hover { box-shadow: var(--shadow-md); }

.forum-answer { margin-bottom: 1rem; margin-left: 0; }

/* --- SOLVED STATE (Purple Theme) --- */
/* This makes the solved answer visually distinct */
.forum-answer.is-solution {
    border: 2px solid var(--brand-dept); /* Purple Border */
    background-color: #fcfaff; /* Very faint purple tint */
    box-shadow: 0 4px 12px rgba(58, 0, 131, 0.08);
    order: -1; /* Flexbox trick to force visual top (backup to SQL) */
}

.solved-text {
    color: var(--brand-dept);
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* Badge for Main Feed */
.solved-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--brand-dept); 
    background-color: #f3e8ff;
    border: 1px solid var(--brand-dept);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

/* --- SUBTLE VOTE CONTROLS (Small Thumbs) --- */
.forum-answer-flex { display: flex; align-items: flex-start; gap: 1rem; }

.vote-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 24px; /* Reduced width */
    padding-top: 4px;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem; /* Much Smaller */
    color: var(--secondary-text-color);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.3; /* Very subtle by default */
    width: 24px;
    height: 24px;
}

.vote-btn:hover { opacity: 1; transform: scale(1.1); }

/* Active States */
.vote-btn.upvote.active { color: var(--brand-dept); opacity: 1; } /* Purple Up */
.vote-btn.downvote.active { color: var(--text-color); opacity: 0.7; } /* Dark Down */

.vote-count {
    font-weight: 600;
    font-size: 0.85rem;
    margin: 2px 0;
    color: var(--secondary-text-color);
}

/* --- METADATA --- */
.forum-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.forum-meta .user {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

.meta-right { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }

.report-btn {
    background: none; border: none;
    color: var(--secondary-text-color);
    font-size: 0.75rem; cursor: pointer;
    padding: 0; opacity: 0.4;
    transition: opacity 0.2s;
}
.report-btn:hover { opacity: 1; color: var(--danger); text-decoration: underline; }

.forum-content {
    font-size: 1rem; line-height: 1.6; color: var(--text-color); white-space: pre-wrap;
}

/* --- LEADERBOARD --- */
.leaderboard-table {
    width: 100%; border-collapse: collapse; background: var(--card-bg);
    border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); margin-top: 1rem;
}
.leaderboard-table th {
    background: var(--bg-secondary); color: var(--brand-dept); font-weight: 700;
    text-align: left; padding: 1rem; border-bottom: 2px solid var(--border-color);
    text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.5px;
}
.leaderboard-table td { padding: 1rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.rank-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%; font-weight: 700;
    background: var(--bg-secondary); color: var(--secondary-text-color); font-size: 0.9rem;
}
.rank-1 .rank-badge { background: #FFD700; color: #7a5c00; }
.rank-2 .rank-badge { background: #C0C0C0; color: #4a4a4a; }
.rank-3 .rank-badge { background: #CD7F32; color: #5a3a1a; }
.points-pill {
    background: #f3e8ff; color: var(--brand-dept); padding: 4px 10px;
    border-radius: 10px; font-weight: 700; font-size: 0.85rem;
}

/* ==========================================================================
   13. RESPONSIVE OPTIMIZATIONS (Mobiles & Tablets)
   ========================================================================== */

/* Tablet (max-width: 992px) */
@media (max-width: 992px) {
    .stats-grid {
        margin-top: -1.5rem; /* Less negative margin on tablet */
        gap: 1rem;
    }
    .content-page {
        padding: 2rem;
        margin: 1rem auto;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    /* Global Break-word to prevent long URLs/text from pushing width */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Heroes and Banners */
    .dashboard-header, .banner, .catalogue-hero {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    .dashboard-header h1, .banner h1, .catalogue-hero h1,
    .dashboard-header h2, .banner h2, .catalogue-hero h2 {
        font-size: 1.7rem;
    }
    .dashboard-header p, .banner p, .catalogue-hero p {
        font-size: 1rem;
    }

    /* Stats Grid */
    .stats-grid {
        margin-top: 1rem; /* Remove negative margin completely to prevent overlap */
        grid-template-columns: 1fr 1fr; /* 2 columns on mobile */
    }

    /* Content Pages */
    .content-page {
        padding: 1.25rem;
        margin: 0.5rem auto;
        border-radius: 8px;
    }

    /* Tables - Prevent Horizontal Scroll Breakage */
    .lesson-content table, .leaderboard-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Timeline Adjustments */
    .timeline-item {
        grid-template-columns: 50px 30px 1fr;
        gap: 0.75rem;
    }
    .timeline-item:not(:last-child)::before {
        left: 64px; /* Shift line to match new tighter grid */
    }
    .timeline-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .timeline-card-action {
        align-self: flex-end;
        margin-top: -2.5rem; /* Pull button up next to content */
    }

    /* Forms & Filters */
    .filter-toolbar, .dashboard-filters {
        padding: 1rem;
        gap: 1rem;
    }
    .filter-group {
        min-width: 100%; /* Full width filters on mobile */
    }
    .auth-container {
        padding: 1.5rem;
        margin: 2rem auto;
    }

    /* Lesson Navigation */
    .lesson-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    .lesson-nav-btn {
        width: 100%;
    }

    /* Tabs */
    .view-tabs {
        padding-bottom: 0.5rem;
    }
    .view-tab-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    /* Hard reset on container padding to give more room and prevent overflow */
    .container {
        padding: 0 10px;
        width: 100%;
    }
    .main-container {
        padding-left: 0;
        padding-right: 0;
    }

    .module-grid {
        grid-template-columns: 1fr; /* Force single column on small phones */
    }
    .stats-grid {
        grid-template-columns: 1fr; /* Single column stats */
    }
    .logo {
        font-size: 1.2rem;
    }
    .user-avatar-hero {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }
    .forum-meta {
        flex-direction: column;
        align-items: flex-start;
    }
    .meta-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }
}

/* ==========================================================================
   14. PRINT STYLES (NEW)
   ========================================================================== */
@media print {
    /* Hide non-essential elements */
    .navbar, .footer-modern, .breadcrumbs, .btn, button, #scrollToTopBtn, #toast-container {
        display: none !important;
    }

    /* Reset Layout for Paper */
    body, .container, .main-container, .auth-container {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }

    .auth-container {
        margin-top: 0 !important;
        border: none !important;
    }

    /* Typography adjustments for print */
    h1, h2, h3, h4 {
        color: #000 !important; /* Force black text */
    }
    
    /* Ensure boxes look good on paper */
    .reflection-content div {
        break-inside: avoid; /* Prevent splitting a question across pages */
        border: 1px solid #ccc !important;
        background-color: #fff !important;
        color: #000 !important;
    }

    /* Add a footer for the printout */
    .container::after {
        content: "Printed from Scribe PDT Learning Platform";
        display: block;
        text-align: center;
        font-size: 10pt;
        color: #666;
        margin-top: 2rem;
        border-top: 1px solid #ccc;
        padding-top: 1rem;
    }
}