/* ================================================================
   QuizAI V2 — Main Stylesheet
   Material Design augmentations for Materialize CSS 1.0
   ================================================================ */

/* ── Base / Reset ─────────────────────────────────────────────── */
:root {
    --primary: #455a64;
    --primary-dark: #263238;
    --accent: #26a69a;
    --danger: #e53935;
    --warning: #ff9800;
    --success: #43a047;
    --info: #1e88e5;
}

html { scroll-behavior: smooth; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Roboto', sans-serif;
    background: #eceff1;
}

main { flex: 1 0 auto; }

/* ── Utility ──────────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }
.p-2  { padding: 1rem !important; }
.p-3  { padding: 1.5rem !important; }
.full-width { width: 100% !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Login ────────────────────────────────────────────────────── */
.login-page {
    background: linear-gradient(135deg, #263238 0%, #455a64 50%, #37474f 100%);
}

.login-wrapper {
    min-height: 100vh;
    width: 100%;
}

.login-page .card {
    border-radius: 8px;
    overflow: hidden;
}

.login-page .card .card-content {
    padding: 2rem 2.5rem;
}

/* ── Navigation ───────────────────────────────────────────────── */
nav .brand-logo {
    display: flex;
    align-items: center;
    font-weight: 500;
    letter-spacing: .5px;
}

nav .brand-logo i { margin-right: .5rem; }

@media only screen and (max-width: 992px) {
    nav .brand-logo { font-size: 1.2rem; left: 50% !important; transform: translateX(-50%); }
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    border-radius: 6px;
    transition: box-shadow .25s ease, transform .15s ease;
}

.card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.12); }

.card .card-title {
    font-weight: 500;
    font-size: 1.2rem;
}

.card .card-action { border-top: 1px solid #e0e0e0; }

/* ── Status Badges ────────────────────────────────────────────── */
.badge-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #fff;
}

.badge-draft      { background: #ff9800; }
.badge-published  { background: #1e88e5; }
.badge-active     { background: #43a047; }
.badge-closed     { background: #9e9e9e; }
.badge-waiting    { background: #78909c; }
.badge-in_progress { background: #26a69a; }
.badge-completed  { background: #43a047; }
.badge-terminated { background: #e53935; }
.badge-sync       { background: #7b1fa2; }
.badge-async      { background: #0288d1; }

/* ── Stats Cards ──────────────────────────────────────────────── */
.stat-card .card-content {
    padding: 1rem 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: .85rem;
    color: #78909c;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Quiz Form ────────────────────────────────────────────────── */
.question-card {
    border-left: 4px solid var(--accent);
    margin-bottom: 1rem;
}

.question-card .question-number {
    font-weight: 700;
    color: var(--primary);
    font-size: .9rem;
}

.choice-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.choice-row:last-child { border-bottom: none; }

.choice-correct {
    color: var(--success);
    font-weight: 500;
}

.choice-image-preview,
.question-image-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    margin-top: .5rem;
}

.add-choice-btn {
    border: 2px dashed #bdbdbd;
    border-radius: 4px;
    padding: .75rem;
    text-align: center;
    color: #9e9e9e;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}

.add-choice-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Quiz Player (Student) ────────────────────────────────────── */
body.quiz-active {
    background: #37474f;
    user-select: none;
    -webkit-user-select: none;
}

body.quiz-active main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 1rem;
}

.quiz-player-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.quiz-header-bar {
    background: var(--primary-dark);
    color: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quiz-header-bar .quiz-title {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Timer */
.timer-display {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: #fff;
    background: rgba(255,255,255,.1);
    border-radius: 8px;
    padding: .5rem 1rem;
    min-width: 80px;
    justify-content: center;
}

.timer-display.timer-warning { color: #ff9800; animation: pulse .8s infinite; }
.timer-display.timer-danger  { color: #e53935; animation: pulse .4s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* Progress */
.quiz-progress {
    padding: .5rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.quiz-progress .progress {
    margin: .5rem 0 0;
    background-color: #cfd8dc;
}

.quiz-progress-text {
    font-size: .85rem;
    color: #78909c;
    font-weight: 500;
}

/* Question */
.question-display {
    background: #fff;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.question-display .question-body {
    padding: 2rem;
}

.question-display .question-text {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: #263238;
}

.question-display .question-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: block;
}

/* Choices */
.choice-option {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: .75rem;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .1s;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.choice-option:hover {
    border-color: var(--accent);
    background: #e0f2f1;
}

.choice-option.selected {
    border-color: var(--accent);
    background: #e0f2f1;
    box-shadow: 0 0 0 2px var(--accent);
}

.choice-option .choice-letter {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eceff1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: var(--primary);
    flex-shrink: 0;
}

.choice-option.selected .choice-letter {
    background: var(--accent);
    color: #fff;
}

.choice-option .choice-content {
    flex: 1;
    font-size: 1rem;
}

.choice-option .choice-content img {
    max-width: 150px;
    max-height: 100px;
    border-radius: 4px;
    margin-top: .5rem;
}

/* Quiz navigation */
.quiz-nav {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
}

/* ── Security Warning Modal ───────────────────────────────────── */
.security-warning-modal .modal-content {
    text-align: center;
}

.security-warning-modal .warning-icon {
    font-size: 4rem;
    color: var(--warning);
}

.terminated-modal .modal-content {
    text-align: center;
}

.terminated-modal .terminated-icon {
    font-size: 4rem;
    color: var(--danger);
}

/* ── Waiting Overlay (Sync) ───────────────────────────────────── */
.sync-waiting {
    text-align: center;
    padding: 3rem;
    color: #fff;
}

.sync-waiting .preloader-wrapper { margin-bottom: 1.5rem; }
.sync-waiting h5 { color: #cfd8dc; }
.sync-waiting p  { color: #90a4ae; }

/* ── Results ──────────────────────────────────────────────────── */
.score-display {
    padding: 2rem;
    text-align: center;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: #fff;
    font-weight: 700;
}

.score-circle .score-pct {
    font-size: 2.5rem;
    line-height: 1;
}

.score-circle .score-label {
    font-size: .85rem;
    opacity: .9;
}

.score-high   { background: var(--success); }
.score-medium { background: var(--warning); }
.score-low    { background: var(--danger); }

.result-question {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.result-question:last-child { border-bottom: none; }

.result-correct { color: var(--success); }
.result-wrong   { color: var(--danger); }

/* ── Live Quiz (Teacher) ──────────────────────────────────────── */
.live-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin: 1rem 0;
}

.live-controls .btn { text-transform: none; }

.live-question-display {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    min-height: 200px;
}

.participant-list .collection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Data Tables ──────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

table.results-table th {
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

table.results-table th:hover { background: #f5f5f5; }

table.results-table tr.row-terminated { background: #ffebee; }

/* ── Loading Overlay ──────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(38, 50, 56, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.bubble {
    float:none;border-radius:12px;padding:2px 10px;
}
.roundedge {
    border-radius:12px;padding:0px 10px 5px 10px;
}
/* ── FAB ──────────────────────────────────────────────────────── */
.fixed-action-btn { bottom: 24px; right: 24px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media only screen and (max-width: 600px) {
    .quiz-player-container { padding: 0; }
    .question-display .question-body { padding: 1.25rem; }
    .question-display .question-text { font-size: 1.05rem; }
    .choice-option { padding: .75rem 1rem; }
    .quiz-nav { padding: 1rem; }
    .timer-display { font-size: 1.2rem; padding: .35rem .75rem; }
    .score-circle { width: 120px; height: 120px; }
    .score-circle .score-pct { font-size: 2rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
}

@media only screen and (max-width: 400px) {
    .login-page .card .card-content { padding: 1.5rem; }
}
