/* ═══════════════════════════════════════════════════════
   RESPONDEAI — App Styles
   ═══════════════════════════════════════════════════════ */

/* ─── Custom Properties — Light ─────────────────────── */
:root {
    --sidebar-width:     240px;
    --sidebar-bg:        #1a1d27;
    --sidebar-active:    rgba(255,255,255,.12);
    --sidebar-hover:     rgba(255,255,255,.07);

    --main-bg:           #f0f2f5;
    --topbar-bg:         #ffffff;
    --topbar-border:     #e9ecef;

    --card-shadow:       0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,.1);
    --card-bg:           #ffffff;

    --option-bg:         #ffffff;
    --option-border:     #dee2e6;
    --option-hover-bg:   #f0f5ff;
    --option-hover-border: #0d6efd;
    --option-sel-bg:     #e7f1ff;
    --option-sel-border: #0d6efd;
    --option-ok-bg:      #d1e7dd;
    --option-ok-border:  #198754;
    --option-wrong-bg:   #f8d7da;
    --option-wrong-border: #dc3545;

    --rank-border:       #f1f3f5;
    --rank-highlight:    #fffbeb;
    --progress-track:    #e9ecef;

    --transition: 0.18s ease;
}

/* ─── Custom Properties — Dark ──────────────────────── */
[data-bs-theme="dark"] {
    --main-bg:           #0d1117;
    --topbar-bg:         #161b22;
    --topbar-border:     #21262d;

    --card-shadow:       0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,.6);
    --card-bg:           #161b22;

    --option-bg:         #1c2128;
    --option-border:     #30363d;
    --option-hover-bg:   #1c2c45;
    --option-hover-border: #4191ff;
    --option-sel-bg:     #1c2c45;
    --option-sel-border: #4191ff;
    --option-ok-bg:      #122a1e;
    --option-ok-border:  #2ea043;
    --option-wrong-bg:   #2a1215;
    --option-wrong-border: #f85149;

    --rank-border:       #21262d;
    --rank-highlight:    #2d2a14;
    --progress-track:    #21262d;
}

/* ─── Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─────────────────────────────────────────── */
.wrapper {
    min-height: 100vh;
    display: flex;
}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition);
    position: relative;
    z-index: 1050;
}

.sidebar-brand {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    letter-spacing: -.2px;
}

.sidebar .nav-link {
    border-radius: 8px;
    padding: .5rem .75rem;
    margin-bottom: 2px;
    font-size: .875rem;
    color: rgba(255,255,255,.65);
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sidebar .nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ─── Sidebar Overlay (mobile) ───────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1049;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

/* ─── Main Content ───────────────────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    background: var(--main-bg);
    display: flex;
    flex-direction: column;
}

/* ─── Topbar ─────────────────────────────────────────── */
.topbar {
    height: 56px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: .75rem;
    transition: background var(--transition), border-color var(--transition);
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Theme Toggle ───────────────────────────────────── */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--topbar-border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    transition: background var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: rgba(0,0,0,.06);
}

[data-bs-theme="dark"] .theme-toggle:hover {
    background: rgba(255,255,255,.08);
}

/* ─── Avatar ─────────────────────────────────────────── */
.avatar, .avatar-sm, .avatar-lg {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    user-select: none;
}

.avatar    { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }

/* ─── Card Improvements ──────────────────────────────── */
.card {
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}

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

/* ─── Quiz Play ──────────────────────────────────────── */
.quiz-card {
    max-width: 680px;
    margin: 0 auto;
}

.timer-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    transition: background .5s;
    flex-shrink: 0;
}

.timer-circle.warning { background: #fd7e14; }
.timer-circle.ok      { background: #198754; }

.option-btn {
    text-align: left;
    padding: .875rem 1.125rem;
    border: 2px solid var(--option-border);
    border-radius: 12px;
    background: var(--option-bg);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform .1s;
    width: 100%;
    color: inherit;
    font-size: inherit;
    line-height: 1.5;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--option-hover-border);
    background: var(--option-hover-bg);
    transform: translateX(3px);
}

.option-btn.selected {
    border-color: var(--option-sel-border);
    background: var(--option-sel-bg);
}

.option-btn.correct {
    border-color: var(--option-ok-border);
    background: var(--option-ok-bg);
}

.option-btn.wrong {
    border-color: var(--option-wrong-border);
    background: var(--option-wrong-bg);
}

/* ─── Progress Bar ───────────────────────────────────── */
.progress-questions {
    height: 6px;
    border-radius: 3px;
    background: var(--progress-track);
    overflow: hidden;
}

.progress-questions .progress-bar {
    border-radius: 3px;
    background: #0d6efd;
    transition: width .4s ease;
}

/* ─── Ranking ────────────────────────────────────────── */
.rank-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--rank-border);
    transition: background var(--transition);
}

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

.rank-item.highlight { background: var(--rank-highlight); }

.rank-position {
    font-weight: 700;
    font-size: 1.1rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.rank-position.top1 { color: #f59e0b; }
.rank-position.top2 { color: #94a3b8; }
.rank-position.top3 { color: #b45309; }

/* ─── Status Badges ──────────────────────────────────── */
.badge-draft     { background: #6c757d; }
.badge-published { background: #198754; }
.badge-closed    { background: #dc3545; }

/* ─── Public Layout ──────────────────────────────────── */
.public-navbar {
    background: var(--sidebar-bg);
    padding: .625rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.public-navbar .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.public-navbar .brand i { color: #fbbf24; }

/* ─── Responsive — Mobile ────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        width: 100%;
    }

    main.p-4 {
        padding: .875rem !important;
    }

    .card-body {
        padding: .875rem;
    }

    .quiz-card {
        padding: 0;
    }

    .option-btn {
        padding: .75rem 1rem;
        font-size: .9375rem;
    }

    .topbar {
        padding: 0 .875rem;
    }
}

@media (min-width: 769px) {
    .sidebar-overlay { display: none !important; }
    #sidebarToggle   { display: none !important; }
}
