/* Design Tokens & CSS Variables from Emergent */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-app: #f0f3f8;
  --bg-sidebar: #111827;
  --bg-sidebar-dark: #0B0F19;
  --primary: #2d5ae0;
  --primary-hover: #2246b8;
  --primary-light: rgba(45, 90, 224, 0.10);
  --secondary: #06b6d4;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --card-bg: rgba(255, 255, 255, 0.75);
  --card-border: rgba(255, 255, 255, 0.60);
  --border-color: rgba(226, 232, 240, 0.80);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* App Shell Layout */
.app-shell {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    font-size: 24px;
    font-weight: 800;
    color: white;
    text-decoration: none;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-group {
    margin-bottom: 30px;
}

.nav-group-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    gap: 12px;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 0 20px rgba(45,90,224,0.35);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    height: 72px;
    min-height: 72px;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 40;
    flex-shrink: 0;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 8px 16px;
    border-radius: 9999px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.user-profile-email {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.user-profile-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Content Area */
.scrollable-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.app-content {
    padding: 32px 40px;
    flex: 1;
}

/* Footer */
.app-footer {
    padding: 24px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}
.app-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* Components UI Réutilisables */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(45,90,224,0.25);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(45,90,224,0.3);
}

.btn-secondary {
    background: var(--primary-light);
    color: var(--primary);
}
.btn-secondary:hover {
    background: rgba(45,90,224,0.15);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Inputs & Forms */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45,90,224,0.15);
}

label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
    margin-bottom: 6px;
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-main);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-success {
    background: rgba(16,185,129,0.12);
    color: #047857;
}
.badge-warning {
    background: rgba(245,158,11,0.12);
    color: #b45309;
}
.badge-danger {
    background: rgba(239,68,68,0.12);
    color: #b91c1c;
}
.badge-info {
    background: var(--primary-light);
    color: var(--primary);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    background: #f8fafc;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.table tbody tr:hover {
    background: #f8fafc;
}

/* Typography */
h1 { font-size: 28px; font-weight: 800; color: var(--text-main); margin-bottom: 24px; margin-top: 0; }
h2 { font-size: 20px; font-weight: 700; color: var(--text-main); margin-bottom: 20px; margin-top: 0; }
h3 { font-size: 16px; font-weight: 600; color: var(--text-main); margin-bottom: 16px; margin-top: 0; }
p { margin-top: 0; margin-bottom: 16px; color: var(--text-muted); }

/* Custom Modals (Emergent Style) */
.emergent-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13,21,38,0.44);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}
.emergent-modal-content {
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(22px);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255,255,255,0.8);
}
.emergent-modal-content.show {
    transform: translateY(0);
}

/* Toast Notifications */
.emergent-toast {
    min-width: 250px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.emergent-toast::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0; width: 4px;
}
.emergent-toast.success::before { background: var(--accent-green); }
.emergent-toast.error::before { background: var(--accent-red); }
.emergent-toast.info::before { background: var(--primary); }


/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .mobile-toggle {
        display: block;
    }
    .app-header {
        padding: 0 20px;
    }
    .app-content {
        padding: 20px;
    }
}

/* Horizontal List Layout for Quizzes */
.quiz-list-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    margin-bottom: 0;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.quiz-list-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px rgba(0,0,0,0.04);
}
.quiz-drag-handle {
    color: #cbd5e1;
    cursor: grab;
    padding-right: 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}
.quiz-drag-handle:active {
    cursor: grabbing;
}
.quiz-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.quiz-list-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quiz-list-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.quiz-list-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon-circle:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background: #fff;
    min-width: 160px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    z-index: 100;
    padding: 5px 0;
}
.dropdown-menu.show {
    display: block;
    animation: fadeInDown 0.15s ease;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}
.dropdown-item:hover {
    background: rgba(45,90,224,0.05);
    color: var(--primary);
}
.dropdown-item.text-danger {
    color: var(--accent-red);
}
.dropdown-item.text-danger:hover {
    background: rgba(239,68,68,0.05);
}

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