/* ================================================
   ACEMEDIX DESIGN SYSTEM v1.0
   EdTech / LMS UI — Primary #0092D2
   Author: Acemedix
   ================================================ */

/* ------------------------------------------------
   1. DESIGN TOKENS (Custom Properties)
   ------------------------------------------------ */
:root {
    /* Brand */
    --ace-primary: #0092D2;
    --ace-primary-dark: #007ab8;
    --ace-primary-darker: #005f8f;
    --ace-primary-light: #e6f4fb;
    --ace-primary-rgb: 0, 146, 210;

    /* Sidebar */
    --ace-sidebar-bg: #1a1a2e;
    --ace-sidebar-text: #8899b0;
    --ace-sidebar-text-hover: #ffffff;
    --ace-sidebar-active-bg: rgba(0, 146, 210, 0.15);
    --ace-sidebar-active-text: #0092D2;
    --ace-sidebar-section-clr: #3a4a62;
    --ace-sidebar-border: rgba(255, 255, 255, 0.06);
    --ace-sidebar-width: 260px;
    --ace-sidebar-collapsed-w: 72px;

    /* Header */
    --ace-header-bg: #ffffff;
    --ace-header-border: #e8ecf0;
    --ace-header-height: 64px;

    /* Surface */
    --ace-bg: #f0f4f8;
    --ace-surface: #ffffff;
    --ace-surface-2: #f8fafc;
    --ace-border: #e2e8f0;

    /* Text */
    --ace-text-primary: #1a202c;
    --ace-text-secondary: #4a5568;
    --ace-text-muted: #718096;
    --ace-text-light: #a0aec0;

    /* Feedback */
    --ace-success: #38a169;
    --ace-success-light: #f0fff4;
    --ace-warning: #d69e2e;
    --ace-warning-light: #fefcbf;
    --ace-danger: #e53e3e;
    --ace-danger-light: #fff5f5;
    --ace-info: #3182ce;
    --ace-info-light: #ebf8ff;

    /* Stat card accent colours */
    --ace-stat-1: #0092D2;
    --ace-stat-2: #38a169;
    --ace-stat-3: #d69e2e;
    --ace-stat-4: #805ad5;

    /* Shadows */
    --ace-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --ace-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --ace-shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --ace-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);

    /* Radius */
    --ace-radius: 12px;
    --ace-radius-sm: 8px;
    --ace-radius-lg: 16px;
    --ace-radius-xl: 24px;
    --ace-radius-full: 9999px;

    /* Transitions */
    --ace-sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --ace-transition: 0.2s ease;

    /* Typography */
    --ace-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------
   2. DARK MODE OVERRIDES
   ------------------------------------------------ */
html[data-theme="dark"] {
    --ace-header-bg: #16213e;
    --ace-header-border: #1e3a5f;

    --ace-bg: #0f0f1a;
    --ace-surface: #16213e;
    --ace-surface-2: #1a2a4a;
    --ace-border: #1e3a5f;

    --ace-text-primary: #e2e8f0;
    --ace-text-secondary: #a0aec0;
    --ace-text-muted: #718096;
    --ace-text-light: #4a5568;

    --ace-sidebar-bg: #0f0f1a;
    --ace-sidebar-text: #6a7a92;
    --ace-sidebar-border: rgba(255, 255, 255, 0.04);
    --ace-sidebar-section-clr: #2a3448;

    --ace-primary-light: rgba(0, 146, 210, 0.12);
    --ace-success-light: rgba(56, 161, 105, 0.12);
    --ace-warning-light: rgba(214, 158, 46, 0.12);
    --ace-danger-light: rgba(229, 62, 62, 0.12);
    --ace-info-light: rgba(49, 130, 206, 0.12);
}

/* ------------------------------------------------
   3. BASE RESET & GLOBAL
   ------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--ace-font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--ace-text-primary);
    background: var(--ace-bg);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--ace-transition), color var(--ace-transition);
}

a {
    color: var(--ace-primary);
    text-decoration: none;
    transition: color var(--ace-transition);
}

a:hover {
    color: var(--ace-primary-dark);
}

img {
    max-width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--ace-text-primary);
    margin-top: 0;
}

/* ------------------------------------------------
   4. LAYOUT — Fixed sidebar + margin-left main
   ------------------------------------------------ */
.ace-layout {
    display: block;
    min-height: 100vh;
}

.ace-main {
    margin-left: var(--ace-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left var(--ace-sidebar-transition);
}

.ace-layout.sidebar-collapsed .ace-main {
    margin-left: var(--ace-sidebar-collapsed-w);
}

/* ------------------------------------------------
   5. SIDEBAR
   ------------------------------------------------ */
.ace-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ace-sidebar-width);
    height: 100vh;
    background: var(--ace-sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--ace-sidebar-transition), width var(--ace-sidebar-transition);
    overflow: hidden;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
}

/* Sidebar Logo Area */
.ace-sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: var(--ace-header-height);
    border-bottom: 1px solid var(--ace-sidebar-border);
    flex-shrink: 0;
}

.ace-sidebar-logo img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.ace-sidebar-close {
    background: none;
    border: none;
    color: var(--ace-sidebar-text);
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    display: none;
    transition: color var(--ace-transition), background var(--ace-transition);
}

.ace-sidebar-close:hover {
    color: var(--ace-sidebar-text-hover);
    background: var(--ace-sidebar-border);
}

/* Sidebar Navigation Scroll Area */
.ace-sidebar-nav-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.ace-sidebar-nav-wrap::-webkit-scrollbar {
    width: 4px;
}

.ace-sidebar-nav-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

/* Section Labels */
.ace-nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ace-sidebar-section-clr);
    padding: 16px 20px 6px;
    user-select: none;
}

/* Nav Items */
.ace-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--ace-sidebar-text);
    font-size: 13.5px;
    font-weight: 450;
    border-radius: 0;
    cursor: pointer;
    transition: background var(--ace-transition), color var(--ace-transition);
    position: relative;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.ace-nav-item:hover {
    color: var(--ace-sidebar-text-hover);
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.ace-nav-item.active {
    color: var(--ace-sidebar-active-text);
    background: var(--ace-sidebar-active-bg);
    font-weight: 500;
}

.ace-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--ace-primary);
    border-radius: 0 3px 3px 0;
}

/* Nav item icon */
.ace-nav-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--ace-transition);
}

.ace-nav-item:hover .ace-nav-icon,
.ace-nav-item.active .ace-nav-icon {
    opacity: 1;
}

/* Nav chevron (for submenus) */
.ace-nav-chevron {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.5;
    transition: transform var(--ace-transition), opacity var(--ace-transition);
    flex-shrink: 0;
}

.ace-nav-toggle[aria-expanded="true"] .ace-nav-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

/* Submenu */
.ace-nav-submenu {
    padding: 0;
}

.ace-nav-sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px 7px 50px;
    color: var(--ace-sidebar-text);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--ace-transition), color var(--ace-transition);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.ace-nav-sub-item:hover {
    color: var(--ace-sidebar-text-hover);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
}

.ace-nav-sub-item.active {
    color: var(--ace-primary);
    font-weight: 500;
}

/* Deep sub-submenu */
.ace-nav-subsub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 20px 6px 66px;
    color: var(--ace-sidebar-text);
    font-size: 12.5px;
    cursor: pointer;
    transition: background var(--ace-transition), color var(--ace-transition);
    text-decoration: none;
}

.ace-nav-subsub-item:hover {
    color: var(--ace-sidebar-text-hover);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
}

.ace-nav-subsub-item.active {
    color: var(--ace-primary);
}

/* Sidebar footer */
.ace-sidebar-footer {
    flex-shrink: 0;
    padding: 12px 20px;
    border-top: 1px solid var(--ace-sidebar-border);
}

.ace-sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--ace-sidebar-text);
    font-size: 13px;
    transition: color var(--ace-transition);
}

.ace-sidebar-footer a:hover {
    color: var(--ace-sidebar-text-hover);
}

/* Overlay (mobile) */
.ace-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    backdrop-filter: blur(2px);
}

.ace-sidebar-overlay.is-visible {
    display: block;
}

/* ------------------------------------------------
   6. HEADER
   ------------------------------------------------ */
.ace-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--ace-header-bg);
    border-bottom: 1px solid var(--ace-header-border);
    height: var(--ace-header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    flex-shrink: 0;
    transition: background var(--ace-transition), border-color var(--ace-transition);
    box-shadow: var(--ace-shadow-sm);
}

.ace-header-brand {
    display: none;
    align-items: center;
}

.ace-header-brand img {
    height: 28px;
}

.ace-header-spacer {
    flex: 1;
}

.ace-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Mobile sidebar toggle */
.ace-sidebar-toggle {
    background: none;
    border: none;
    color: var(--ace-text-secondary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ace-radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: background var(--ace-transition), color var(--ace-transition);
    flex-shrink: 0;
}

.ace-sidebar-toggle:hover {
    background: var(--ace-primary-light);
    color: var(--ace-primary);
}

/* Icon buttons in header */
.ace-icon-btn {
    background: none;
    border: none;
    color: var(--ace-text-secondary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ace-radius-sm);
    cursor: pointer;
    font-size: 15px;
    transition: background var(--ace-transition), color var(--ace-transition);
    position: relative;
    border: 1px solid transparent;
}

.ace-icon-btn:hover {
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    border-color: var(--ace-primary-light);
}

/* Notification badge */
.ace-notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--ace-danger);
    border-radius: 50%;
    border: 2px solid var(--ace-header-bg);
}

/* User avatar in header */
.ace-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--ace-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color var(--ace-transition);
}

.ace-user-avatar:hover {
    border-color: var(--ace-primary);
}

.ace-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Header Dropdowns */
.ace-dropdown {
    position: relative;
}

.ace-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--ace-surface);
    border: 1px solid var(--ace-border);
    border-radius: var(--ace-radius);
    box-shadow: var(--ace-shadow-md);
    z-index: 1050;
    display: none;
    overflow: hidden;
    animation: dropdownIn 0.15s ease;
}

.ace-dropdown-menu.show {
    display: block;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

.ace-dropdown-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--ace-border);
}

.ace-dropdown-header .user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ace-text-primary);
}

.ace-dropdown-header .user-email {
    font-size: 12px;
    color: var(--ace-text-muted);
}

.ace-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--ace-text-secondary);
    font-size: 13.5px;
    transition: background var(--ace-transition), color var(--ace-transition);
    cursor: pointer;
    text-decoration: none;
}

.ace-dropdown-item:hover {
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    text-decoration: none;
}

.ace-dropdown-item i {
    width: 16px;
    text-align: center;
}

.ace-dropdown-divider {
    margin: 4px 0;
    border-top: 1px solid var(--ace-border);
}

/* Notification dropdown (wider) */
.ace-notif-dropdown {
    min-width: 320px;
}

.ace-notif-dropdown-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--ace-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ace-notif-dropdown-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.ace-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ace-border);
    transition: background var(--ace-transition);
    cursor: pointer;
    text-decoration: none;
}

.ace-notif-item:hover {
    background: var(--ace-primary-light);
    text-decoration: none;
}

.ace-notif-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ace-notif-text {
    font-size: 13px;
    color: var(--ace-text-secondary);
    line-height: 1.5;
}

.ace-notif-footer {
    padding: 10px 16px;
    text-align: center;
}

.ace-notif-footer a {
    font-size: 13px;
    font-weight: 500;
    color: var(--ace-primary);
}

/* ------------------------------------------------
   7. CONTENT AREA
   ------------------------------------------------ */
.ace-content {
    flex: 1;
    padding: 24px;
}

/* Page header */
.ace-page-header {
    margin-bottom: 24px;
}

.ace-page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ace-text-primary);
    margin: 0 0 4px;
}

.ace-page-subtitle {
    font-size: 14px;
    color: var(--ace-text-muted);
    margin: 0;
}

/* ------------------------------------------------
   8. CARDS
   ------------------------------------------------ */
.ace-card {
    background: var(--ace-surface);
    border-radius: var(--ace-radius);
    border: 1px solid var(--ace-border);
    box-shadow: var(--ace-shadow-sm);
    transition: box-shadow var(--ace-transition), background var(--ace-transition), border-color var(--ace-transition);
    overflow: hidden;
}

.ace-card:hover {
    box-shadow: var(--ace-shadow);
}

.ace-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ace-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ace-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ace-text-primary);
    margin: 0;
}

.ace-card-subtitle {
    font-size: 12.5px;
    color: var(--ace-text-muted);
    margin: 2px 0 0;
}

.ace-card-body {
    padding: 20px;
}

.ace-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--ace-border);
    background: var(--ace-surface-2);
}

/* ------------------------------------------------
   9. STAT CARDS (KPI)
   ------------------------------------------------ */
.ace-stat-card {
    background: var(--ace-surface);
    border-radius: var(--ace-radius);
    border: 1px solid var(--ace-border);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--ace-shadow-sm);
    transition: box-shadow var(--ace-transition), transform var(--ace-transition), background var(--ace-transition);
    overflow: hidden;
    position: relative;
}

.ace-stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ace-stat-accent, var(--ace-primary));
}

.ace-stat-card:hover {
    box-shadow: var(--ace-shadow-md);
    transform: translateY(-2px);
}

.ace-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--ace-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--ace-stat-icon-bg, var(--ace-primary-light));
    color: var(--ace-stat-accent, var(--ace-primary));
}

.ace-stat-content {
    flex: 1;
    min-width: 0;
}

.ace-stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--ace-text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.ace-stat-label {
    font-size: 12.5px;
    color: var(--ace-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ace-stat-change {
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
}

.ace-stat-change.up {
    color: var(--ace-success);
}

.ace-stat-change.down {
    color: var(--ace-danger);
}

/* Stat card colour variants */
.ace-stat-card[data-accent="blue"] {
    --ace-stat-accent: #0092D2;
    --ace-stat-icon-bg: #e6f4fb;
}

.ace-stat-card[data-accent="green"] {
    --ace-stat-accent: #38a169;
    --ace-stat-icon-bg: #f0fff4;
}

.ace-stat-card[data-accent="yellow"] {
    --ace-stat-accent: #d69e2e;
    --ace-stat-icon-bg: #fefcbf;
}

.ace-stat-card[data-accent="purple"] {
    --ace-stat-accent: #805ad5;
    --ace-stat-icon-bg: #faf5ff;
}

html[data-theme="dark"] .ace-stat-card[data-accent="blue"] {
    --ace-stat-icon-bg: rgba(0, 146, 210, 0.12);
}

html[data-theme="dark"] .ace-stat-card[data-accent="green"] {
    --ace-stat-icon-bg: rgba(56, 161, 105, 0.12);
}

html[data-theme="dark"] .ace-stat-card[data-accent="yellow"] {
    --ace-stat-icon-bg: rgba(214, 158, 46, 0.12);
}

html[data-theme="dark"] .ace-stat-card[data-accent="purple"] {
    --ace-stat-icon-bg: rgba(128, 90, 213, 0.12);
}

/* ------------------------------------------------
   10. MODULE QUICK-ACCESS CARDS
   ------------------------------------------------ */
.ace-module-card {
    background: var(--ace-surface);
    border-radius: var(--ace-radius);
    border: 1px solid var(--ace-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    box-shadow: var(--ace-shadow-sm);
    transition: box-shadow var(--ace-transition), transform var(--ace-transition), border-color var(--ace-transition), background var(--ace-transition);
    text-decoration: none;
    cursor: pointer;
    height: 100%;
}

.ace-module-card:hover {
    box-shadow: var(--ace-shadow-md);
    transform: translateY(-3px);
    border-color: var(--ace-primary);
    text-decoration: none;
}

.ace-module-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--ace-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ace-module-name {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ace-text-primary);
    margin: 0;
}

.ace-module-desc {
    font-size: 12.5px;
    color: var(--ace-text-muted);
    margin: 0;
    line-height: 1.5;
}

.ace-module-arrow {
    margin-top: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background var(--ace-transition), transform var(--ace-transition);
}

.ace-module-card:hover .ace-module-arrow {
    background: var(--ace-primary);
    color: #fff;
    transform: translateX(3px);
}

/* Module icon colour variants */
.ace-module-icon.blue {
    background: #e6f4fb;
    color: #0092D2;
}

.ace-module-icon.green {
    background: #f0fff4;
    color: #38a169;
}

.ace-module-icon.orange {
    background: #fffaf0;
    color: #dd6b20;
}

.ace-module-icon.purple {
    background: #faf5ff;
    color: #805ad5;
}

.ace-module-icon.pink {
    background: #fff5f7;
    color: #d53f8c;
}

.ace-module-icon.teal {
    background: #e6fffa;
    color: #319795;
}

.ace-module-icon.yellow {
    background: #fefcbf;
    color: #d69e2e;
}

.ace-module-icon.cyan {
    background: #e0f7ff;
    color: #00b5d8;
}

html[data-theme="dark"] .ace-module-icon.blue {
    background: rgba(0, 146, 210, 0.12);
}

html[data-theme="dark"] .ace-module-icon.green {
    background: rgba(56, 161, 105, 0.12);
}

html[data-theme="dark"] .ace-module-icon.orange {
    background: rgba(221, 107, 32, 0.12);
}

html[data-theme="dark"] .ace-module-icon.purple {
    background: rgba(128, 90, 213, 0.12);
}

html[data-theme="dark"] .ace-module-icon.pink {
    background: rgba(213, 63, 140, 0.12);
}

html[data-theme="dark"] .ace-module-icon.teal {
    background: rgba(49, 151, 149, 0.12);
}

html[data-theme="dark"] .ace-module-icon.yellow {
    background: rgba(214, 158, 46, 0.12);
}

html[data-theme="dark"] .ace-module-icon.cyan {
    background: rgba(0, 181, 216, 0.12);
}

/* ------------------------------------------------
   11. LEADERBOARD ITEMS
   ------------------------------------------------ */
.ace-lb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ace-border);
    transition: background var(--ace-transition);
}

.ace-lb-item:last-child {
    border-bottom: none;
}

.ace-lb-item.ace-lb-you {
    background: var(--ace-primary-light);
    margin: 0 -20px;
    padding: 10px 20px;
    border-radius: var(--ace-radius-sm);
    border-bottom-color: transparent;
}

.ace-lb-rank {
    width: 24px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--ace-text-muted);
    flex-shrink: 0;
}

.ace-lb-rank.gold {
    color: #c9a50a;
}

.ace-lb-rank.silver {
    color: #8a9bb0;
}

.ace-lb-rank.bronze {
    color: #a0683a;
}

.ace-lb-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}

.ace-lb-badge.gold {
    background: #ffd700;
    color: #7a6100;
}

.ace-lb-badge.silver {
    background: #c0c0c0;
    color: #4a4a4a;
}

.ace-lb-badge.bronze {
    background: #cd7f32;
    color: #fff;
}

.ace-lb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ace-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.ace-lb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ace-lb-name {
    flex: 1;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ace-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ace-lb-name small {
    display: block;
    font-size: 11px;
    color: var(--ace-text-muted);
    font-weight: 400;
}

.ace-lb-score {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ace-text-primary);
    flex-shrink: 0;
}

.ace-lb-change {
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}

.ace-lb-change.up {
    color: var(--ace-success);
}

.ace-lb-change.down {
    color: var(--ace-danger);
}

.ace-lb-change.same {
    color: var(--ace-text-muted);
}

/* You badge */
.ace-you-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--ace-primary);
    color: #fff;
    padding: 2px 6px;
    border-radius: var(--ace-radius-full);
    flex-shrink: 0;
}

/* ------------------------------------------------
   12. AVATARS
   ------------------------------------------------ */
.ace-avatar {
    border-radius: 50%;
    background: var(--ace-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.ace-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ace-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.ace-avatar-md {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.ace-avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

.ace-avatar-xl {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

/* ------------------------------------------------
   13. PROGRESS BARS
   ------------------------------------------------ */
.ace-progress {
    height: 6px;
    background: var(--ace-border);
    border-radius: var(--ace-radius-full);
    overflow: hidden;
}

.ace-progress-bar {
    height: 100%;
    border-radius: var(--ace-radius-full);
    background: var(--ace-primary);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ace-progress-bar.green {
    background: var(--ace-success);
}

.ace-progress-bar.yellow {
    background: var(--ace-warning);
}

.ace-progress-bar.red {
    background: var(--ace-danger);
}

.ace-progress-bar.purple {
    background: #805ad5;
}

/* ------------------------------------------------
   14. BADGES
   ------------------------------------------------ */
.ace-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--ace-radius-full);
    font-size: 11.5px;
    font-weight: 600;
}

.ace-badge-primary {
    background: var(--ace-primary-light);
    color: var(--ace-primary);
}

.ace-badge-success {
    background: var(--ace-success-light);
    color: var(--ace-success);
}

.ace-badge-warning {
    background: var(--ace-warning-light);
    color: var(--ace-warning);
}

.ace-badge-danger {
    background: var(--ace-danger-light);
    color: var(--ace-danger);
}

.ace-badge-info {
    background: var(--ace-info-light);
    color: var(--ace-info);
}

.ace-badge-purple {
    background: #faf5ff;
    color: #805ad5;
}

/* ------------------------------------------------
   15. BUTTONS
   ------------------------------------------------ */
.ace-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--ace-radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--ace-transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.ace-btn:hover {
    text-decoration: none;
}

.ace-btn-primary {
    background: var(--ace-primary);
    color: #fff;
    border-color: var(--ace-primary);
}

.ace-btn-primary:hover {
    background: var(--ace-primary-dark);
    border-color: var(--ace-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 146, 210, 0.35);
}

.ace-btn-outline {
    background: transparent;
    color: var(--ace-primary);
    border-color: var(--ace-primary);
}

.ace-btn-outline:hover {
    background: var(--ace-primary);
    color: #fff;
}

.ace-btn-ghost {
    background: transparent;
    color: var(--ace-text-secondary);
    border-color: var(--ace-border);
}

.ace-btn-ghost:hover {
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    border-color: var(--ace-primary);
}

.ace-btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
}

.ace-btn-lg {
    padding: 11px 24px;
    font-size: 15px;
}

/* ------------------------------------------------
   16. EVENT BANNER
   ------------------------------------------------ */
.ace-event-banner {
    background: linear-gradient(135deg, var(--ace-primary) 0%, var(--ace-primary-dark) 100%);
    border-radius: var(--ace-radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.ace-event-banner::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.ace-event-banner::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: 60px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.ace-event-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--ace-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ace-event-body {
    flex: 1;
    min-width: 0;
}

.ace-event-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    opacity: 0.7;
}

.ace-event-title {
    font-size: 15px;
    font-weight: 600;
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ace-event-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.ace-event-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: background var(--ace-transition);
}

.ace-event-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ------------------------------------------------
   17. WELCOME HEADER
   ------------------------------------------------ */
.ace-welcome {
    margin-bottom: 24px;
}

.ace-welcome-greeting {
    font-size: 22px;
    font-weight: 700;
    color: var(--ace-text-primary);
    margin: 0 0 2px;
}

.ace-welcome-sub {
    font-size: 14px;
    color: var(--ace-text-muted);
    margin: 0;
}

/* ------------------------------------------------
   18. FOOTER
   ------------------------------------------------ */
.ace-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--ace-border);
    background: var(--ace-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 13px;
    color: var(--ace-text-muted);
    flex-shrink: 0;
}

.ace-footer a {
    color: var(--ace-text-muted);
}

.ace-footer a:hover {
    color: var(--ace-primary);
}

.ace-footer-links {
    display: flex;
    gap: 16px;
}

/* ------------------------------------------------
   19. MESSAGES / ALERTS
   ------------------------------------------------ */
.ace-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--ace-radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    margin-bottom: 16px;
}

.ace-alert-success {
    background: var(--ace-success-light);
    border-color: #c6f6d5;
    color: #276749;
}

.ace-alert-warning {
    background: var(--ace-warning-light);
    border-color: #faf089;
    color: #7b6600;
}

.ace-alert-danger {
    background: var(--ace-danger-light);
    border-color: #fed7d7;
    color: #9b2c2c;
}

.ace-alert-info {
    background: var(--ace-info-light);
    border-color: #bee3f8;
    color: #2a6496;
}

.ace-alert-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--ace-transition);
    font-size: 14px;
    flex-shrink: 0;
}

.ace-alert-dismiss:hover {
    opacity: 1;
}

/* ------------------------------------------------
   20. DARK MODE TOGGLE SWITCH
   ------------------------------------------------ */
.ace-theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.ace-toggle-track {
    width: 36px;
    height: 20px;
    background: var(--ace-border);
    border-radius: 10px;
    position: relative;
    transition: background var(--ace-transition);
}

html[data-theme="dark"] .ace-toggle-track {
    background: var(--ace-primary);
}

.ace-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--ace-transition), box-shadow var(--ace-transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .ace-toggle-thumb {
    transform: translateX(16px);
}

/* ------------------------------------------------
   21. TABLE STYLES
   ------------------------------------------------ */
.ace-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.ace-table th {
    background: var(--ace-surface-2);
    color: var(--ace-text-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--ace-border);
    white-space: nowrap;
}

.ace-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ace-border);
    color: var(--ace-text-secondary);
    vertical-align: middle;
}

.ace-table tr:last-child td {
    border-bottom: none;
}

.ace-table tr:hover td {
    background: var(--ace-surface-2);
}

/* ------------------------------------------------
   22. CHART CONTAINER
   ------------------------------------------------ */
.ace-chart-wrap {
    position: relative;
    width: 100%;
}

/* ------------------------------------------------
   23. RESPONSIVE
   ------------------------------------------------ */
@media (max-width: 991.98px) {
    .ace-main {
        margin-left: 0;
    }

    .ace-sidebar {
        transform: translateX(-100%);
    }

    .ace-sidebar.is-open {
        transform: translateX(0);
    }

    .ace-sidebar-close {
        display: flex;
    }

    .ace-header-brand {
        display: flex;
    }

    .ace-content {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .ace-stat-card {
        padding: 14px;
    }

    .ace-stat-value {
        font-size: 20px;
    }

    .ace-card-body {
        padding: 14px;
    }

    .ace-content {
        padding: 12px;
    }

    .ace-welcome-greeting {
        font-size: 18px;
    }
}

/* ------------------------------------------------
   24. WATERMARK (lightweight, theme-aware)
   ------------------------------------------------ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('/static/images/logo.png');
    background-repeat: repeat;
    background-size: 180px auto;
    opacity: 0.018;
    pointer-events: none;
    z-index: 0;
}

html[data-theme="dark"] body::before {
    opacity: 0.012;
}

/* ------------------------------------------------
   25. UTILITY OVERRIDES
   ------------------------------------------------ */
.text-primary-ace {
    color: var(--ace-primary) !important;
}

.bg-primary-ace {
    background: var(--ace-primary) !important;
}

.border-primary-ace {
    border-color: var(--ace-primary) !important;
}

/* Ensure Bootstrap components inherit theme */
.card {
    background: var(--ace-surface);
    border-color: var(--ace-border);
    border-radius: var(--ace-radius);
}

.card-body {
    color: var(--ace-text-secondary);
}

.form-control,
.form-select {
    background: var(--ace-surface);
    border-color: var(--ace-border);
    color: var(--ace-text-primary);
    border-radius: var(--ace-radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ace-primary);
    box-shadow: 0 0 0 3px rgba(0, 146, 210, 0.15);
    background: var(--ace-surface);
    color: var(--ace-text-primary);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background: var(--ace-surface);
    border-color: var(--ace-border);
    color: var(--ace-text-primary);
}

/* ------------------------------------------------
   26. SPINNER / LOADING
   ------------------------------------------------ */
.ace-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--ace-border);
    border-top-color: var(--ace-primary);
    border-radius: 50%;
    animation: aceSpinnerSpin 0.7s linear infinite;
}

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

/* ------------------------------------------------
   27. SCROLLBAR (global for main content)
   ------------------------------------------------ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ace-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ace-text-light);
}

/* ------------------------------------------------
   28. QUIZ COMPONENTS
   ------------------------------------------------ */

/* Answer choice items */
.ace-answer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--ace-radius-sm);
    border: 1.5px solid var(--ace-border);
    background: var(--ace-surface);
    cursor: pointer;
    transition: border-color var(--ace-transition), background var(--ace-transition), transform var(--ace-transition);
    margin-bottom: 8px;
    user-select: none;
    text-decoration: none;
    color: var(--ace-text-primary);
}

.ace-answer-item:last-child {
    margin-bottom: 0;
}

.ace-answer-item:hover:not(.ace-answer-correct):not(.ace-answer-wrong):not(.ace-answer-missed) {
    border-color: var(--ace-primary);
    background: var(--ace-primary-light);
    transform: translateX(2px);
}

.ace-answer-item.selected {
    border-color: var(--ace-primary);
    background: var(--ace-primary-light);
}

.ace-answer-item.ace-answer-correct {
    background: var(--ace-success-light);
    border-color: var(--ace-success);
}

.ace-answer-item.ace-answer-wrong {
    background: var(--ace-danger-light);
    border-color: var(--ace-danger);
}

.ace-answer-item.ace-answer-missed {
    background: var(--ace-success-light);
    border-color: var(--ace-success);
}

.ace-answer-item.ace-answer-dim {
    opacity: 0.55;
    pointer-events: none;
}

.ace-answer-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--ace-border);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #fff;
    transition: all var(--ace-transition);
}

.ace-answer-item.selected .ace-answer-radio {
    background: var(--ace-primary);
    border-color: var(--ace-primary);
}

.ace-answer-item.ace-answer-correct .ace-answer-radio {
    background: var(--ace-success);
    border-color: var(--ace-success);
}

.ace-answer-item.ace-answer-wrong .ace-answer-radio {
    background: var(--ace-danger);
    border-color: var(--ace-danger);
}

.ace-answer-item.ace-answer-missed .ace-answer-radio {
    background: var(--ace-success);
    border-color: var(--ace-success);
}

.ace-answer-text {
    flex: 1;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ace-text-primary);
}

/* Question navigation pills */
.ace-q-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ace-q-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: var(--ace-primary-light);
    color: var(--ace-primary);
    border: 1.5px solid transparent;
    transition: all var(--ace-transition);
}

.ace-q-pill:hover {
    background: var(--ace-primary);
    color: #fff;
    text-decoration: none;
}

.ace-q-pill.correct {
    background: var(--ace-success-light);
    color: var(--ace-success);
    border-color: #c6f6d5;
}

.ace-q-pill.wrong {
    background: var(--ace-danger-light);
    color: var(--ace-danger);
    border-color: #fed7d7;
}

.ace-q-pill.active {
    background: var(--ace-primary);
    color: #fff;
}

/* Explanation box */
.ace-explanation {
    background: var(--ace-primary-light);
    border-left: 3px solid var(--ace-primary);
    border-radius: var(--ace-radius-sm);
    padding: 16px 18px;
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--ace-text-primary);
}

/* Progress card (view_progress) */
.ace-progress-card {
    background: var(--ace-surface);
    border: 1px solid var(--ace-border);
    border-radius: var(--ace-radius);
    padding: 20px;
    box-shadow: var(--ace-shadow-sm);
    transition: box-shadow var(--ace-transition), transform var(--ace-transition);
    height: 100%;
}

.ace-progress-card:hover {
    box-shadow: var(--ace-shadow-md);
    transform: translateY(-2px);
}

/* Deck cards (flashcards) */
.ace-deck-card {
    border-radius: var(--ace-radius);
    border: 1px solid var(--ace-border);
    overflow: hidden;
    box-shadow: var(--ace-shadow-sm);
    transition: box-shadow var(--ace-transition), transform var(--ace-transition);
    height: 100%;
    background: var(--ace-surface);
}

.ace-deck-card:hover {
    box-shadow: var(--ace-shadow-md);
    transform: translateY(-2px);
}

.ace-deck-card-thumb,
.ace-deck-card-color {
    height: 6px;
    width: 100%;
}

/* ── Input ─────────────────────────────────────────────────────────── */
.ace-input {
    background: var(--ace-surface);
    border: 1.5px solid var(--ace-border);
    border-radius: 8px;
    color: var(--ace-text-primary);
    padding: 9px 14px;
    font-size: 14px;
    transition: border-color var(--ace-transition);
    outline: none;
}

.ace-input:focus {
    border-color: var(--ace-primary);
}

html[data-theme="dark"] .ace-input {
    background: var(--ace-surface-2);
}

/* ── Success button variant ────────────────────────────────────────── */
.ace-btn-success {
    background: var(--ace-success);
    color: #fff;
    border-color: var(--ace-success);
}

.ace-btn-success:hover {
    background: #2f855a;
    border-color: #2f855a;
    color: #fff;
}

.ace-deck-card-body {
    padding: 18px;
}

.ace-deck-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ace-text-primary);
    margin: 0 0 6px;
}

.ace-deck-card-meta {
    font-size: 13px;
    color: var(--ace-text-muted);
    margin: 0 0 14px;
}

/* Dark mode quiz overrides */
html[data-theme="dark"] .ace-answer-item {
    background: var(--ace-surface-2);
}

html[data-theme="dark"] .ace-answer-radio {
    border-color: var(--ace-text-muted);
    background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .ace-answer-item.ace-answer-correct {
    background: rgba(56, 161, 105, 0.1);
}

html[data-theme="dark"] .ace-answer-item.ace-answer-wrong {
    background: rgba(229, 62, 62, 0.1);
}

html[data-theme="dark"] .ace-answer-item.ace-answer-missed {
    background: rgba(56, 161, 105, 0.1);
}

html[data-theme="dark"] .ace-explanation {
    background: rgba(0, 146, 210, 0.1);
}

html[data-theme="dark"] .ace-progress-card {
    background: var(--ace-surface);
}

html[data-theme="dark"] .ace-deck-card {
    background: var(--ace-surface);
}

/* ── Dark mode: Bootstrap overrides ── */
html[data-theme="dark"] .text-muted {
    color: var(--ace-text-muted) !important;
}

html[data-theme="dark"] .modal-content {
    background: var(--ace-surface);
    color: var(--ace-text-primary);
    border-color: var(--ace-border);
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--ace-border);
}

html[data-theme="dark"] .modal-title {
    color: var(--ace-text-primary);
}

html[data-theme="dark"] .modal-body {
    color: var(--ace-text-secondary);
}

/* Close button visible on dark surfaces */
html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}