/* ============================================================
   STUDENT DASHBOARD - Questudy Design System
   Namespace: qsd-*
   ============================================================ */

/* ===== Hero Header ===== */
.qsd-hero {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    border-radius: 20px;
    padding: 40px 36px;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    position: relative;
    overflow: hidden;
    color: #fff;
}

.qsd-hero::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.qsd-hero::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -5%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.qsd-hero-text { position: relative; z-index: 1; flex: 1; }

.qsd-hero-greeting {
    display: block;
    font-size: 15px;
    font-weight: 600;
    opacity: 0.85;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.qsd-hero-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.qsd-hero-sub {
    font-size: 15px;
    opacity: 0.8;
    margin: 0;
    line-height: 1.5;
}

/* ===== Streak Ring ===== */
.qsd-hero-streak {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,0.12);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 16px 24px 16px 16px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.qsd-hero-streak.is-active {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.35);
    box-shadow: 0 0 30px rgba(255,255,255,0.1);
}

.qsd-streak-ring {
    width: 80px;
    height: 80px;
    position: relative;
    flex-shrink: 0;
}

.qsd-streak-svg { width: 100%; height: 100%; }

.qsd-streak-fire {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.qsd-streak-num {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    margin-top: 14px;
}

.qsd-streak-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qsd-streak-label {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.qsd-streak-best {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

.qsd-streak-warn {
    font-size: 11px;
    color: #fbbf24;
    font-weight: 600;
}

/* ===== Stat Cards Row ===== */
.qsd-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.qsd-stat-card {
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 16px;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--questudy-shadow);
    transition: all 0.25s ease;
}

.qsd-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--questudy-shadow-lg);
}

.qsd-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.qsd-stat-purple::before { background: linear-gradient(90deg, #6366f1, #a855f7); }
.qsd-stat-blue::before { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.qsd-stat-amber::before { background: linear-gradient(90deg, #f59e0b, #f97316); }
.qsd-stat-green::before { background: linear-gradient(90deg, #10b981, #34d399); }

.qsd-stat-icon {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 4px;
}

.qsd-stat-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    color: var(--questudy-text);
    letter-spacing: -1px;
}

.qsd-stat-label {
    font-size: 13px;
    color: var(--questudy-text-light);
    font-weight: 500;
}

/* ===== Daily Goal Row ===== */
.qsd-goal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.qsd-goal-card {
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 16px;
    padding: 28px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: var(--questudy-shadow);
}

.qsd-goal-ring-wrap {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    position: relative;
}

.qsd-goal-svg { width: 100%; height: 100%; }

.qsd-goal-pct {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 800;
    color: var(--questudy-text);
}

.qsd-goal-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.qsd-goal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--questudy-text);
}

.qsd-goal-detail {
    font-size: 13px;
    color: var(--questudy-text-light);
    line-height: 1.4;
}

.qsd-goal-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--questudy-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.qsd-goal-cta:hover { color: var(--questudy-primary-hover); }

/* ===== Goal Setter ===== */
.qsd-goal-setter {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--questudy-border);
}

.qsd-goal-setter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--questudy-text-light);
    display: block;
    margin-bottom: 6px;
}

.qsd-goal-setter-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.qsd-goal-input {
    width: 60px;
    height: 32px;
    border: 1px solid var(--questudy-border);
    border-radius: 8px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--questudy-text);
    background: var(--questudy-card-bg);
    text-align: center;
}

.qsd-goal-input:focus {
    outline: none;
    border-color: var(--questudy-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.qsd-goal-save-btn {
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: var(--questudy-primary);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.qsd-goal-save-btn:hover { background: var(--questudy-primary-hover); }
.qsd-goal-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Subject Mini Panel ===== */
.qsd-subject-mini {
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--questudy-shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qsd-subject-mini-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--questudy-text);
}

.qsd-subject-mini-row {
    display: grid;
    grid-template-columns: 100px 1fr 42px;
    align-items: center;
    gap: 10px;
}

.qsd-subject-mini-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--questudy-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qsd-subject-mini-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.qsd-subject-mini-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.qsd-subject-mini-pct {
    font-size: 12px;
    font-weight: 700;
    text-align: right;
}

/* ===== Section Styling ===== */
.qsd-section {
    margin-bottom: 28px;
}

.qsd-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--questudy-text);
    margin: 0 0 16px;
}

/* ===== Badges Row ===== */
.qsd-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.qsd-badge-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: var(--questudy-shadow);
    transition: all 0.2s ease;
}

.qsd-badge-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--questudy-shadow-md);
    border-color: var(--questudy-primary);
}

.qsd-badge-icon { font-size: 22px; line-height: 1; }

.qsd-badge-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--questudy-text);
}

/* ===== 2-Column Grid ===== */
.qsd-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===== Subject Performance Bars ===== */
.qsd-subject-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.qsd-subject-row {
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--questudy-shadow);
}

.qsd-subject-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.qsd-subject-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--questudy-text);
}

.qsd-subject-pct {
    font-size: 14px;
    font-weight: 800;
}

.qsd-subject-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.qsd-subject-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.qsd-subject-meta {
    font-size: 11px;
    color: var(--questudy-text-light);
}

/* ===== Activity Timeline ===== */
.qsd-timeline {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qsd-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    border: 1px solid transparent;
}

.qsd-timeline-item:hover {
    background: var(--questudy-primary-light);
    border-color: rgba(99,102,241,0.1);
}

.qsd-timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.qsd-timeline-content {
    flex: 1;
    min-width: 0;
}

.qsd-timeline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.qsd-timeline-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--questudy-text);
}

.qsd-timeline-score {
    font-size: 14px;
    font-weight: 800;
}

.qsd-timeline-sub {
    display: flex;
    gap: 6px;
    font-size: 12px;
    color: var(--questudy-text-light);
    margin-top: 2px;
}

/* ===== Weak Areas Grid ===== */
.qsd-weak-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.qsd-weak-card {
    background: var(--questudy-card-bg);
    border: 1px solid var(--questudy-border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--questudy-shadow);
    transition: all 0.2s ease;
}

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

.qsd-weak-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.qsd-weak-topic {
    font-size: 14px;
    font-weight: 600;
    color: var(--questudy-text);
}

.qsd-weak-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.qsd-weak-detail {
    font-size: 12px;
    color: var(--questudy-text-light);
    margin: 0 0 10px;
}

.qsd-weak-bar {
    height: 5px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.qsd-weak-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ===== Quick Actions Grid ===== */
.qsd-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.qsd-action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 28px 22px;
    border-radius: 16px;
    text-decoration: none;
    color: #fff;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    min-height: 140px;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.08);
    background-color: #1e293b;
}

.qsd-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.22);
    border-color: rgba(255,255,255,0.25);
}

.qsd-action-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    border-radius: 16px;
    z-index: 0;
}

.qsd-action-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(20px, -20px);
    z-index: 1;
}

.qsd-action-card > * { position: relative; z-index: 2; }

.qsd-action-grad-1::before { background: linear-gradient(135deg, rgba(99,102,241,0.85), rgba(139,92,246,0.85)); }
.qsd-action-grad-2::before { background: linear-gradient(135deg, rgba(59,130,246,0.85), rgba(14,165,233,0.85)); }
.qsd-action-grad-3::before { background: linear-gradient(135deg, rgba(5,150,105,0.85), rgba(6,182,212,0.85)); }
.qsd-action-grad-4::before { background: linear-gradient(135deg, rgba(217,119,6,0.85), rgba(245,158,11,0.85)); }
.qsd-action-grad-5::before { background: linear-gradient(135deg, rgba(220,38,38,0.85), rgba(236,72,153,0.85)); }
.qsd-action-grad-6::before { background: linear-gradient(135deg, rgba(124,58,237,0.85), rgba(217,70,239,0.85)); }
.qsd-action-grad-7::before { background: linear-gradient(135deg, rgba(14,165,233,0.85), rgba(16,185,129,0.85)); }

.qsd-action-icon {
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.qsd-action-label {
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
    line-height: 1.3;
}

.qsd-action-desc {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    line-height: 1.3;
}

/* ===== Global Dark Mode (all frontend pages) ===== */
body.questudy-dark-mode {
    --questudy-bg: #0f172a;
    --questudy-card-bg: #1e293b;
    --questudy-border: #334155;
    --questudy-text: #f1f5f9;
    --questudy-text-light: #94a3b8;
    --questudy-primary-light: rgba(99,102,241,0.15);
}

body.questudy-dark-mode .qsd-hero {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #7c3aed 100%);
}

body.questudy-dark-mode .qsd-streak-warn { color: #fbbf24; }

body.questudy-dark-mode .qsd-subject-bar,
body.questudy-dark-mode .qsd-subject-mini-bar,
body.questudy-dark-mode .qsd-weak-bar { background: #334155; }

body.questudy-dark-mode .qsd-action-card { box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
body.questudy-dark-mode .qsd-badge-item { background: #1e293b; border-color: #334155; }
body.questudy-dark-mode .qsd-weak-card { background: #1e293b; border-color: #334155; }
body.questudy-dark-mode .qsd-subject-row { background: #1e293b; border-color: #334155; }
body.questudy-dark-mode .qsd-goal-card { background: #1e293b; border-color: #334155; }
body.questudy-dark-mode .qsd-subject-mini { background: #1e293b; border-color: #334155; }

body.questudy-dark-mode .qsd-timeline-item:hover {
    background: rgba(99,102,241,0.1);
}

/* ===== Dark Mode Toggle Button ===== */
.qsd-dark-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--questudy-primary);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    z-index: 9999;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qsd-dark-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(99,102,241,0.5);
}

body.questudy-dark-mode .qsd-dark-toggle {
    background: #f59e0b;
    box-shadow: 0 4px 16px rgba(245,158,11,0.4);
}

/* ===== CBT Keyboard Shortcuts Modal ===== */
.cbt-shortcuts-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.cbt-shortcuts-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.cbt-shortcuts-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cbtFadeIn 0.2s ease;
}

.cbt-shortcuts-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.cbt-shortcuts-content {
    position: relative;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    color: #f1f5f9;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    max-height: 80vh;
    overflow-y: auto;
}

.cbt-shortcuts-content h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.cbt-shortcuts-content .cbt-sc-subtitle {
    font-size: 13px;
    color: #94a3b8;
    margin: 0 0 20px;
}

.cbt-shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
}

.cbt-shortcut-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(51,65,85,0.5);
}

.cbt-shortcut-row:last-child,
.cbt-shortcut-row:nth-last-child(2):nth-child(odd) {
    border-bottom: none;
}

.cbt-shortcut-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: nowrap;
}

.cbt-shortcut-desc {
    font-size: 13px;
    color: #cbd5e1;
}

.cbt-shortcuts-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.cbt-shortcuts-close:hover { color: #fff; }

@keyframes cbtFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
.qsd-hero {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
        flex-direction: column;
        text-align: center;
        padding: 32px 24px;
    }
    .qsd-hero-streak { align-self: center; }
    .qsd-stat-row { grid-template-columns: repeat(2, 1fr); }
    .qsd-goal-row { grid-template-columns: 1fr; }
    .qsd-grid-2col { grid-template-columns: 1fr; }
    .qsd-actions-grid { grid-template-columns: repeat(2, 1fr); }
    .cbt-shortcuts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .qsd-hero-title { font-size: 24px; }
    .qsd-stat-row { grid-template-columns: 1fr 1fr; gap: 12px; }
    .qsd-stat-card { padding: 16px 14px; min-height: auto; }
    .qsd-stat-value { font-size: 26px; }
    .qsd-actions-grid { grid-template-columns: 1fr; }
    .qsd-goal-card { flex-direction: column; text-align: center; align-items: center; }
    .qsd-subject-mini-row { grid-template-columns: 80px 1fr 36px; }
    .qsd-weak-grid { grid-template-columns: 1fr; }
}
