/* ===== QuizGame Stylesheet ===== */

:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --accent: #e94560;
    --accent2: #4ecca3;
    --accent3: #f9b208;
    --accent4: #3a86ff;
    --text: #e0e0e0;
    --text-muted: #8892b0;
    --border: #233;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, opacity 0.15s;
    color: white;
}
.btn:hover { transform: translateY(-2px); opacity: 0.9; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); }
.btn-secondary { background: var(--accent4); }
.btn-accent { background: var(--accent2); }
.btn-warning { background: var(--accent3); color: #1a1a2e; }
.btn-danger { background: #c0392b; }
.btn-large { padding: 16px 40px; font-size: 20px; }
.btn-small { padding: 6px 14px; font-size: 14px; }

/* ===== Index page ===== */
.index-page {
    display: flex;
    align-items: center;
    justify-content: center;
}
.index-container {
    text-align: center;
}
.index-container h1 { font-size: 3rem; margin-bottom: 10px; }
.subtitle { color: var(--text-muted); font-size: 1.2rem; margin-bottom: 40px; }
.index-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}
.admin-status { margin-top: 30px; color: var(--accent2); }

/* ===== Forms / Inputs ===== */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 16px;
    width: 100%;
    margin-bottom: 10px;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}
label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* ===== Login ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    width: 400px;
    max-width: 90vw;
}
.login-card h2 { text-align: center; margin-bottom: 30px; }
.login-error {
    color: var(--accent);
    text-align: center;
    margin-bottom: 15px;
    font-size: 14px;
}

/* ===== Editor ===== */
.editor-layout { max-width: 1200px; margin: 0 auto; padding: 20px; }
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.editor-header h1 { font-size: 1.8rem; }
.game-list { display: grid; gap: 12px; }
.game-list-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.15s;
    border: 2px solid transparent;
}
.game-list-item:hover { border-color: var(--accent); }
.game-list-item .meta { color: var(--text-muted); font-size: 14px; }

/* Slide editor */
.slide-editor { display: flex; gap: 20px; }
.slide-list-panel { width: 240px; flex-shrink: 0; }
.slide-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 70vh;
    overflow-y: auto;
}
.slide-list-item {
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.slide-list-item.active { border-color: var(--accent); }
.slide-list-item .type-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.type-badge.info { background: var(--accent4); }
.type-badge.quiz { background: var(--accent3); color: #1a1a2e; }
.type-badge.text { background: var(--accent2); color: #1a1a2e; }

.slide-edit-panel { flex: 1; }
.answer-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}
.answer-row input { margin-bottom: 0; }
.answer-correct {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.answer-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Presenter ===== */
.presenter-page { max-width: 100%; }
.presenter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--bg-card);
}
.presenter-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 75vh;
    padding: 30px;
    position: relative;
}

/* Lobby */
.lobby-container { text-align: center; }
.lobby-container h1 { font-size: 2.5rem; margin-bottom: 10px; }
.join-code-display {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 10px;
    color: var(--accent2);
    margin: 20px 0;
}
.qr-container {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    display: inline-block;
    margin: 20px 0;
}
.qr-container img { display: block; }
.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}
.player-chip {
    background: var(--bg-input);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    animation: pop-in 0.3s ease;
}
@keyframes pop-in {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Question display */
.question-display {
    text-align: center;
    width: 100%;
    max-width: 900px;
}
.question-title {
    font-size: 2.5rem;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
}
.question-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.answer-box {
    padding: 30px;
    border-radius: var(--radius);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s;
}
.answer-box.color-0 { background: #e74c3c; }
.answer-box.color-1 { background: #3498db; }
.answer-box.color-2 { background: #f1c40f; color: #1a1a2e; }
.answer-box.color-3 { background: #2ecc71; color: #1a1a2e; }
.answer-box.correct { outline: 4px solid #2ecc71; }
.answer-box.wrong { opacity: 0.4; }
.answer-box .count-badge {
    position: absolute;
    bottom: 5px;
    right: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 2px 10px;
    font-size: 14px;
}

/* Timer */
.timer-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}
.timer-fill {
    height: 100%;
    background: var(--accent2);
    transition: width 1s linear;
    border-radius: 4px;
}
.timer-fill.urgent { background: var(--accent); }
.timer-number {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 20px;
}
.timer-number.urgent { color: var(--accent); }

/* Leaderboard */
.leaderboard {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
}
.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 8px;
    animation: slide-in 0.3s ease;
}
@keyframes slide-in {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.leaderboard-row .rank { font-size: 1.5rem; font-weight: 800; width: 50px; }
.leaderboard-row .name { flex: 1; font-size: 1.2rem; }
.leaderboard-row .score { font-weight: 600; color: var(--accent2); }
.leaderboard-row.top-1 .rank { color: #ffd700; }
.leaderboard-row.top-2 .rank { color: #c0c0c0; }
.leaderboard-row.top-3 .rank { color: #cd7f32; }

/* Final results */
.final-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin: 30px 0;
}
.podium-place {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    min-width: 150px;
}
.podium-place.p1 { background: linear-gradient(#ffd700, #b8860b); height: 200px; order: 2; color: #1a1a2e; }
.podium-place.p2 { background: linear-gradient(#c0c0c0, #808080); height: 150px; order: 1; color: #1a1a2e; }
.podium-place.p3 { background: linear-gradient(#cd7f32, #8b4513); height: 100px; order: 3; color: #1a1a2e; }
.podium-place .position { font-size: 2rem; font-weight: 800; }
.podium-place .player-name { font-size: 1.2rem; margin: 5px 0; }
.podium-place .player-score { font-size: 1rem; }

/* ===== Player (mobile) ===== */
.player-page {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.player-page h1 { text-align: center; font-size: 1.8rem; margin-bottom: 20px; }

.join-form { text-align: center; }
.nickname-form { text-align: center; }

.waiting-page {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}
.waiting-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-input);
    border-top: 4px solid var(--accent2);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player-question {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.player-question-title {
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-card);
    border-radius: var(--radius);
}
.player-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}
.player-answer-btn {
    padding: 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s;
    color: white;
}
.player-answer-btn:active { transform: scale(0.97); }
.player-answer-btn.color-0 { background: #e74c3c; }
.player-answer-btn.color-1 { background: #3498db; }
.player-answer-btn.color-2 { background: #f1c40f; color: #1a1a2e; }
.player-answer-btn.color-3 { background: #2ecc71; color: #1a1a2e; }
.player-answer-btn.selected { outline: 4px solid white; }
.player-answer-btn:disabled { opacity: 0.6; }

.player-text-input {
    width: 100%;
    padding: 20px;
    font-size: 1.2rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    margin-bottom: 15px;
}

.player-answer-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.answer-correct-icon { font-size: 4rem; margin-bottom: 15px; }
.answer-status-text { font-size: 1.4rem; margin-bottom: 10px; }
.points-gained { font-size: 1.8rem; color: var(--accent2); font-weight: 800; }

.player-timer-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    margin-bottom: 15px;
    overflow: hidden;
}
.player-timer-fill {
    height: 100%;
    background: var(--accent2);
    transition: width 0.3s linear;
}

/* Background images */
.slide-background {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.25;
    z-index: 0;
}
.slide-background.full-opacity {
    opacity: 1;
}
.slide-content { position: relative; z-index: 1; width: 100%; }

/* Info slide */
.info-slide {
    text-align: center;
    padding: 20px;
}
.info-slide h2 { font-size: 2.5rem; }

/* Info slide on mobile (player) */
.player-page .info-slide h2 { font-size: 1.3rem; }
.player-page .info-slide p { font-size: 0.95rem; line-height: 1.5; }

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.flex-gap-10 { display: flex; gap: 10px; align-items: center; }

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 9999;
    animation: toast-in 0.3s ease;
}
@keyframes toast-in {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
.toast.error { border: 1px solid var(--accent); }