/* ========================================
   EduQuiz — Custom App Styles
   ======================================== */

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

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    background-image: radial-gradient(circle, #d4d4f7 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--fw-bold);
    color: var(--color-text);
}

.text-primary { color: var(--color-primary) !important; }
.text-accent { color: var(--color-accent) !important; }
.text-muted { color: var(--color-muted) !important; }

/* ========================================
   Header Bar
   ======================================== */
.navbar-eduquiz {
    background-color: var(--color-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 0.5rem 1.5rem;
    z-index: 1050;
}

.navbar-eduquiz .navbar-brand {
    font-weight: var(--fw-black);
    color: var(--color-primary);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-eduquiz .navbar-brand i {
    font-size: 1.6rem;
}

.role-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
}

.role-badge-admin {
    background-color: var(--color-accent);
    color: #fff;
}

.role-badge-student {
    background-color: var(--color-secondary);
    color: #fff;
}

/* ========================================
   Admin Sidebar
   ======================================== */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--color-surface);
    box-shadow: 2px 0 16px rgba(0,0,0,0.06);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-logo {
    padding: 1rem 1.5rem;
    font-weight: var(--fw-black);
    font-size: 1.3rem;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #f1f1f5;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #d8d8e0 transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d0d0d8; border-radius: 4px; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-weight: var(--fw-semibold);
    font-size: 0.95rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-right: 0.5rem;
    transition: all 0.2s;
}

.sidebar-nav li a:hover {
    background-color: #f0f4ff;
    color: var(--color-primary);
}

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

.sidebar-nav li a i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f1f1f5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
    font-size: 0.8rem;
}

.admin-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* ========================================
   Cards
   ======================================== */
.card-edu {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: none;
    overflow: hidden;
}

.card-edu .card-body {
    padding: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: none;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-number {
    font-size: 2.2rem;
    font-weight: var(--fw-black);
    color: var(--color-text);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    position: absolute;
    top: 1rem;
    right: 1rem;
    opacity: 0.15;
}

.stat-card-primary { border-left: 4px solid var(--color-primary); }
.stat-card-secondary { border-left: 4px solid var(--color-secondary); }
.stat-card-accent { border-left: 4px solid var(--color-accent); }
.stat-card-success { border-left: 4px solid var(--color-success); }

/* ========================================
   Buttons
   ======================================== */
.btn-edu {
    border-radius: var(--radius-md);
    font-weight: var(--fw-bold);
    font-family: var(--font-main);
    padding: 0.65rem 1.5rem;
    border: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-btn);
    cursor: pointer;
}

.btn-edu:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0px rgba(0,0,0,0.15);
}

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

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

.btn-secondary-edu {
    background-color: var(--color-secondary);
    color: #fff;
}

.btn-accent-edu {
    background-color: var(--color-accent);
    color: #fff;
}

.btn-danger-edu {
    background-color: var(--color-danger);
    color: #fff;
}

.btn-success-edu {
    background-color: var(--color-success);
    color: #fff;
}

/* ========================================
   Answer Buttons
   ======================================== */
.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
}

.answer-grid.five-answers {
    grid-template-columns: 1fr 1fr 1fr;
}

.answer-btn {
    min-height: 100px;
    border: none;
    border-radius: var(--radius-lg);
    color: #fff;
    font-weight: var(--fw-bold);
    font-size: 1.1rem;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-answer);
    position: relative;
    animation: bounceIn 0.5s ease forwards;
    opacity: 0;
}

.answer-btn:nth-child(1) { background-color: var(--answer-1); animation-delay: 0ms; }
.answer-btn:nth-child(2) { background-color: var(--answer-2); animation-delay: 100ms; }
.answer-btn:nth-child(3) { background-color: var(--answer-3); animation-delay: 200ms; }
.answer-btn:nth-child(4) { background-color: var(--answer-4); animation-delay: 300ms; }
.answer-btn:nth-child(5) { background-color: var(--answer-5); animation-delay: 400ms; }

.answer-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 4px rgba(0,0,0,0.18);
}

.answer-btn:active {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 2px 0px rgba(0,0,0,0.18);
}

.answer-btn.selected {
    outline: 4px solid #fff;
    outline-offset: -4px;
}

.answer-btn.dimmed {
    opacity: 0.4;
    pointer-events: none;
}

.answer-btn.correct {
    animation: correctPulse 0.8s ease infinite;
}

.answer-btn.wrong {
    animation: shakeWrong 0.5s ease;
}

.answer-icon {
    font-size: 1.4rem;
    min-width: 28px;
    text-align: center;
}

/* ========================================
   Timer
   ======================================== */
.timer-circle {
    width: 100px;
    height: 100px;
    position: relative;
    margin: 0 auto;
}

.timer-circle svg {
    transform: rotate(-90deg);
    width: 100px;
    height: 100px;
}

.timer-circle .timer-bg {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 8;
}

.timer-circle .timer-progress {
    fill: none;
    stroke: var(--color-success);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-circle .timer-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: var(--fw-black);
    color: var(--color-text);
}

.timer-circle.warning .timer-progress { stroke: var(--color-accent); }
.timer-circle.danger .timer-progress { stroke: var(--color-danger); }
.timer-circle.danger { animation: shakeWrong 0.3s ease infinite; }

/* ========================================
   Score Bar (Student bottom)
   ======================================== */
.score-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    padding: 0.75rem 1.5rem;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
    text-align: center;
    z-index: 1030;
    font-weight: var(--fw-bold);
    font-size: 1.1rem;
}

.score-bar .score-value {
    color: var(--color-accent);
    font-weight: var(--fw-black);
}

.score-bar .score-value.shimmer {
    background: linear-gradient(
        90deg,
        var(--color-accent) 0%,
        #fbbf24 50%,
        var(--color-accent) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 1.5s ease-in-out;
}

/* ========================================
   Feedback Overlay
   ======================================== */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.feedback-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 420px;
    width: 90%;
    animation: scorePop 0.5s ease;
}

.feedback-card.correct {
    border-top: 6px solid var(--color-success);
}

.feedback-card.wrong {
    border-top: 6px solid var(--color-danger);
}

.feedback-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.feedback-score {
    font-size: 2rem;
    font-weight: var(--fw-black);
    animation: scorePop 0.6s ease 0.2s both;
}

.feedback-score.positive { color: var(--color-success); }
.feedback-score.negative { color: var(--color-danger); }

/* ========================================
   Leaderboard
   ======================================== */
.podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    min-height: 300px;
}

.podium-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: podiumRise 0.8s ease forwards;
    transform-origin: bottom;
}

.podium-block.first  { order: 2; }
.podium-block.second { order: 1; }
.podium-block.third  { order: 3; }

.podium-bar {
    width: 120px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem 0.5rem;
    color: #fff;
    font-weight: var(--fw-bold);
}

.podium-bar.first {
    height: 200px;
    background: linear-gradient(180deg, #f59e0b, #d97706);
    animation-delay: 0.2s;
}

.podium-bar.second {
    height: 150px;
    background: linear-gradient(180deg, #94a3b8, #64748b);
    animation-delay: 0.4s;
}

.podium-bar.third {
    height: 110px;
    background: linear-gradient(180deg, #b45309, #92400e);
    animation-delay: 0.6s;
}

.podium-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    border: 3px solid rgba(255,255,255,0.5);
}

.podium-name {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    text-align: center;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-score {
    font-size: 1rem;
    font-weight: var(--fw-black);
}

.podium-medal {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    animation: slideInRow 0.4s ease forwards;
    opacity: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.rank-row.highlight {
    border-left: 4px solid var(--color-primary);
    background: #f0f4ff;
}

.rank-number {
    font-weight: var(--fw-black);
    font-size: 1.1rem;
    min-width: 30px;
    text-align: center;
    color: var(--color-muted);
}

.rank-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
    font-size: 0.8rem;
    color: #fff;
}

.rank-name { flex: 1; font-weight: var(--fw-semibold); }

.rank-score {
    font-weight: var(--fw-black);
    color: var(--color-accent);
}

.rank-delta {
    font-size: 0.8rem;
    font-weight: var(--fw-bold);
}

.rank-delta.up { color: var(--color-success); }
.rank-delta.down { color: var(--color-danger); }

/* ========================================
   Question Results Bar Chart
   ======================================== */
.results-bar-container {
    margin-top: 1rem;
}

.result-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-bar-label {
    min-width: 60px;
    font-weight: var(--fw-semibold);
    font-size: 0.85rem;
    text-align: right;
}

.result-bar-track {
    flex: 1;
    height: 32px;
    background: #e5e7eb;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.result-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: #fff;
    font-weight: var(--fw-bold);
    font-size: 0.8rem;
    min-width: fit-content;
}

.result-bar-fill.correct {
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.result-bar-count {
    min-width: 50px;
    text-align: right;
    font-weight: var(--fw-semibold);
    font-size: 0.85rem;
    color: var(--color-muted);
}

/* ========================================
   OTP Input
   ======================================== */
.otp-inputs {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.otp-inputs input {
    width: 60px;
    height: 70px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: var(--fw-bold);
    border: 2px solid #d1d5db;
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font-main);
}

.otp-inputs input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.otp-inputs input.filled {
    border-color: var(--color-primary);
}

/* ========================================
   Lobby
   ======================================== */
.lobby-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    padding: 2rem;
    text-align: center;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.session-code-pill {
    display: inline-block;
    background: #fff;
    color: var(--color-primary);
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: var(--fw-black);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    letter-spacing: 4px;
}

.participant-count {
    font-size: 4rem;
    font-weight: var(--fw-black);
    color: var(--color-primary);
    line-height: 1;
}

.participant-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    padding: 1.5rem;
}

.participant-bubble {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: var(--fw-bold);
    font-size: 0.75rem;
    animation: bounceIn 0.4s ease forwards;
}

/* ========================================
   Countdown Overlay (3-2-1)
   ======================================== */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.countdown-number {
    font-size: 8rem;
    font-weight: var(--fw-black);
    color: #fff;
    animation: countdownPop 1s ease forwards;
}

/* ========================================
   Confetti
   ======================================== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2500;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFloat 3s ease forwards;
}

/* ========================================
   Banner Carousel
   ======================================== */
.banner-carousel {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    margin-bottom: 1.5rem;
}

.banner-slides {
    display: flex;
    transition: transform 0.5s ease;
}

.banner-slide {
    min-width: 100%;
    padding: 2rem;
    text-align: center;
}

.banner-slide.text-banner {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    font-size: 1.2rem;
    font-weight: var(--fw-bold);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-slide.image-banner {
    padding: 0;
}

.banner-slide.image-banner img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.banner-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
}

.banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.banner-dot.active {
    background: var(--color-primary);
    width: 24px;
    border-radius: 4px;
}

/* ========================================
   Live Session Admin
   ======================================== */
.live-layout {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 1.5rem;
    min-height: calc(100vh - 180px);
}

.live-control-bar {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    background: var(--color-surface);
    padding: 1rem 2rem;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1030;
}

/* ========================================
   Status Badge
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: var(--fw-bold);
    text-transform: uppercase;
}

.status-badge.waiting {
    background: #f3f4f6;
    color: #6b7280;
}

.status-badge.active {
    background: #d1fae5;
    color: #059669;
}

.status-badge.active::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #059669;
    animation: pulse 1.5s ease infinite;
}

.status-badge.ended {
    background: #fee2e2;
    color: #dc2626;
}

/* ========================================
   Tables
   ======================================== */
.table-edu {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.table-edu thead th {
    background: #f8fafc;
    border: none;
    font-weight: var(--fw-bold);
    color: var(--color-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 1rem;
}

.table-edu tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table-edu tbody tr:hover {
    background: #f8fafc;
}

/* ========================================
   Forms
   ======================================== */
.form-control-edu {
    border: 2px solid #e5e7eb;
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    font-family: var(--font-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control-edu:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-control-edu.form-control-lg {
    padding: 0.85rem 1.2rem;
    font-size: 1.15rem;
}

/* ========================================
   Misc Utilities
   ======================================== */
.bg-primary-gradient {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.animate-bounce-in {
    animation: bounceIn 0.5s ease forwards;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-pulse {
    animation: pulse 1.5s ease infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.loading-dots span {
    display: inline-block;
    animation: loadingDots 1.4s ease infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

.text-gradient {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .admin-content { margin-left: 0; padding: 1rem; }
    .live-layout { grid-template-columns: 1fr; }
    .live-control-bar { left: 0; }
    .answer-grid { grid-template-columns: 1fr; }
    .podium-container { flex-direction: column; align-items: center; }
    .podium-block { order: unset !important; }
}
