/* quiz/assets/css/quiz.css */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root { 
    --bg-color: #0f172a; --text-color: #e2e8f0; --card-bg: #1e293b; 
    --btn-bg: #dc5f00; --btn-hover: #ff7b21; --accent: #f59e0b; 
    --border: rgba(255,255,255,0.08); --muted: #94a3b8; 
    --option-1: #dc5f00; --option-2: #475569; --option-3: #f59e0b; --option-4: #10b981;
    --transition: all .2s ease; 
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: "Tajawal", sans-serif; background: var(--bg-color); color: var(--text-color); 
    transition: var(--transition); direction: rtl;
}

/* ==========================================
   BASE LAYOUT (Matches your exam-active)
   ========================================== */
body.quiz-mode { 
    position: fixed; inset: 0; width: 100%; height: 100%; 
    display: flex; flex-direction: column; background: var(--bg-color); overflow: hidden; 
}

/* Overlays (Lobby, Results, Podium) */
.quiz-overlay {
    display: none; position: fixed; inset: 0; background: var(--bg-color);
    flex-direction: column; align-items: center; justify-content: center;
    padding: 20px; z-index: 50; text-align: center;
    animation: fadeIn 0.3s ease;
}
.quiz-overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }

/* The Flex Question Layout */
#quiz-layout { 
    display: none; flex-direction: column; flex: 1; min-height: 0;
}
#quiz-layout.active { display: flex; }

/* 1. TOP BAR */
.quiz-header { 
    flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; 
    padding: 12px 20px; background: var(--card-bg); 
    border-bottom: 1px solid var(--border); z-index: 10;
}
.quiz-header-timer { 
    display: flex; align-items: center; gap: 8px; background: rgba(245, 158, 11, 0.1); 
    color: var(--accent); padding: 8px 16px; border-radius: 20px; font-weight: 800; font-size: 16px;
}
.quiz-header-timer.danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.quiz-header-score { font-weight: 700; color: var(--muted); font-size: 15px;}
.quiz-header-score span { color: var(--text-color); }

/* 2. MIDDLE AREA (Scrollable Question) */
#q-box { 
    flex: 1; min-height: 0; overflow-y: auto; 
    padding: 30px 24px 20px 24px; 
}
.question-inner { width: 100%; max-width: 800px; margin: 0 auto; }
.question-text { font-size: 20px; font-weight: 800; line-height: 1.8; margin-bottom: 20px; color: var(--text-color); }
.responsive-image { max-width: 100%; height: auto; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,.3); }

/* 3. BOTTOM DOCK (Options Grid) */
.quiz-dock { 
    flex-shrink: 0; background: var(--bg-color); 
    border-top: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); /* IPHONE FIX */
}

/* Option Buttons */
.option-btn {
    padding: 18px 15px; border-radius: 16px; border: none;
    font-size: 16px; font-weight: 700; color: white; cursor: pointer;
    text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: var(--transition); box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-family: "Tajawal", sans-serif;
}
.option-btn:active { transform: scale(0.95); }
.option-btn.disabled { pointer-events: none; opacity: 0.5; filter: grayscale(0.5); }
.option-btn .key { font-size: 20px; opacity: 0.8; }

.option-btn.color-0 { background-color: var(--option-1); }
.option-btn.color-1 { background-color: var(--option-2); }
.option-btn.color-2 { background-color: var(--option-3); color: #000; }
.option-btn.color-3 { background-color: var(--option-4); }

.option-btn.selected { outline: 4px solid #fff; outline-offset: 2px; transform: scale(1.02); }

/* ==========================================
   JOIN & LOBBY SCREENS
   ========================================== */
.join-card { background: var(--card-bg); padding: 40px 30px; border-radius: 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.4); width: 100%; max-width: 400px; }
.join-card h1 { color: var(--btn-bg); margin-bottom: 30px; font-size: 32px; }
.join-card input {
    width: 100%; padding: 16px 20px; margin: 12px 0; border-radius: 14px;
    border: 2px solid var(--border); background: var(--bg-color); color: var(--text-color);
    font-size: 18px; font-family: "Tajawal", sans-serif; outline: none;
}
.join-card input:focus { border-color: var(--btn-bg); }
.error-msg { color: #ef4444; font-size: 14px; margin-top: 10px; display: none; background: rgba(239,68,68,0.1); padding: 10px; border-radius: 8px;}

.lobby-pin { font-size: 50px; font-weight: 800; color: var(--btn-bg); letter-spacing: 10px; margin: 20px 0; text-shadow: 0 0 20px rgba(220, 95, 0, 0.4); }
.lobby-players-list { margin-top: 30px; width: 100%; max-width: 400px; background: var(--card-bg); border-radius: 16px; padding: 15px; max-height: 300px; overflow-y: auto; border: 1px solid var(--border);}
.lobby-player { padding: 12px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ==========================================
   RESULT & FEEDBACK
   ========================================== */
.result-feedback { font-size: 48px; font-weight: 800; margin-bottom: 10px; }
.result-correct { color: var(--option-4); }
.result-wrong { color: #ef4444; }
.result-points { font-size: 20px; color: var(--muted); margin-bottom: 20px; background: var(--card-bg); padding: 15px 30px; border-radius: 12px; border: 1px solid var(--border);}
.result-points strong { color: var(--accent); font-size: 24px; }

/* ==========================================
   PODIUM & LEADERBOARD
   ========================================== */
.podium-container { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-bottom: 40px; width: 100%; max-width: 500px; height: 300px; }
.podium-item { display: flex; flex-direction: column; align-items: center; width: 34%; border-radius: 16px 16px 0 0; padding: 20px 10px 0; position: relative; transition: all 0.5s ease; }
.podium-item .podium-name { font-weight: 800; font-size: 16px; text-align: center; word-wrap: break-word; margin-bottom: auto; color: #000; }
.podium-item .podium-score { font-size: 22px; font-weight: 800; margin-bottom: 15px; color: #000; }
.podium-item.rank-1 { height: 75%; background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%); order: 2; box-shadow: 0 0 30px rgba(245, 158, 11, 0.5); }
.podium-item.rank-2 { height: 55%; background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%); order: 1; }
.podium-item.rank-3 { height: 40%; background: linear-gradient(180deg, #f97316 0%, #ea580c 100%); order: 3; }
.final-others-list { width: 100%; max-width: 500px; margin-top: 20px; }
.final-other-item { display: flex; justify-content: space-between; background: var(--card-bg); padding: 14px 20px; margin: 8px 0; border-radius: 12px; border: 1px solid var(--border); font-weight: 600;}

/* Points Animation */
.points-popup { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 60px; font-weight: 800; color: var(--accent); text-shadow: 0 0 20px rgba(245, 158, 11, 0.8); pointer-events: none; z-index: 1000; animation: floatUp 1.5s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); } 30% { opacity: 1; transform: translate(-50%, -70%) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -150%) scale(1); } }

/* Teacher Disconnect Warning */
.disconnect-warning { background: rgba(239, 68, 68, 0.9); color: white; padding: 15px; text-align: center; font-weight: 700; position: fixed; bottom: 0; left: 0; right: 0; z-index: 999; backdrop-filter: blur(4px); animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 0.8; } 50% { opacity: 1; } 100% { opacity: 0.8; } }

/* ==========================================
   TEACHER HOST STYLES
   ========================================== */
.host-container { padding: 20px; max-width: 1200px; margin: 0 auto; background: var(--bg-color); min-height: 100vh;}
.host-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.host-panel { background: var(--card-bg); padding: 25px; border-radius: 16px; border: 1px solid var(--border); }
.host-panel h3 { margin-bottom: 20px; color: var(--btn-bg); font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 10px;}

.session-code-box { text-align: center; background: rgba(220,95,0,0.1); padding: 15px 30px; border-radius: 12px; border: 2px dashed var(--btn-bg); }
.session-code-text { font-size: 40px; font-weight: 800; letter-spacing: 10px; color: var(--btn-bg); }

.host-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .host-grid { grid-template-columns: 1fr; } }

.teacher-question-display { font-size: 18px; margin: 20px 0; line-height: 1.8; color: var(--text-color); }
.answer-dist-bar { display: flex; align-items: center; margin: 12px 0; }
.answer-dist-key { width: 40px; font-weight: 800; color: var(--muted); }
.answer-dist-bar-bg { flex: 1; height: 30px; background: var(--bg-color); border-radius: 15px; overflow: hidden; margin: 0 15px; border: 1px solid var(--border); }
.answer-dist-bar-fill { height: 100%; border-radius: 15px; display: flex; align-items: center; padding-left: 10px; font-size: 12px; font-weight: 700; color: rgba(0,0,0,0.8); transition: width 0.8s cubic-bezier(0.25, 1, 0.5, 1); }
.answer-dist-count { width: 50px; text-align: left; font-weight: 700; color: var(--muted); }

/* Standardized Button */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 24px; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; transition: var(--transition); color: white; background: var(--btn-bg); font-family: "Tajawal", sans-serif; }
.btn:hover { background: var(--btn-hover); }
.btn-ghost { background: var(--card-bg); color: var(--text-color); border: 1px solid var(--border); }
.btn-success { background: var(--option-4); }
.btn-large { font-size: 20px; padding: 20px 40px; }