/* ============================================================
   QUIZ SYSTEM - FRONT-END STYLES
   Standalone design: lobby, test, result pages
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

/* ---- BASE ---- */
.quiz-body {
    margin: 0;
    padding: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    color: #333;
    direction: rtl;
}

/* ---- LOBBY ---- */
.quiz-lobby {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-lobby-container {
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.quiz-lobby-title {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.quiz-lobby-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.quiz-cards {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.quiz-card {
    background: rgba(255,255,255,0.95);
    border-radius: 16px;
    padding: 36px 28px;
    width: 280px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.quiz-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 50px rgba(0,0,0,0.25);
}

.quiz-card-icon {
    color: #302b63;
    margin-bottom: 16px;
}

.quiz-card-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #302b63;
    margin-bottom: 8px;
}

.quiz-card-desc {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.quiz-card-btn {
    background: linear-gradient(135deg, #302b63, #24243e);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}

.quiz-card-btn:hover {
    opacity: 0.9;
}

/* ---- MODAL (front-end) ---- */
.quiz-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.quiz-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.quiz-modal-close {
    position: absolute;
    top: 12px;
    left: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.quiz-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #302b63;
    margin-bottom: 24px;
    text-align: center;
}

.quiz-form-group {
    margin-bottom: 18px;
}

.quiz-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: #444;
}

.quiz-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.quiz-form-group input:focus {
    border-color: #302b63;
    outline: none;
}

.quiz-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #302b63, #24243e);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

.quiz-submit-btn:hover {
    opacity: 0.9;
    color: #fff;
}

/* ---- TEST PAGE ---- */
.quiz-test-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-loading {
    text-align: center;
    color: #fff;
}

.quiz-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.quiz-error {
    text-align: center;
    color: #fff;
    max-width: 400px;
}

.quiz-error-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

#quiz-test {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* Test Header */
.quiz-test-header {
    background: #302b63;
    color: #fff;
    padding: 16px 24px;
}

.quiz-test-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.quiz-test-type {
    font-weight: 600;
    font-size: 1rem;
}

.quiz-test-timer {
    font-size: 1.1rem;
    font-weight: 700;
    background: rgba(255,255,255,0.15);
    padding: 4px 14px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.quiz-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: #f39c12;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-progress-text {
    text-align: center;
    font-size: 0.85rem;
    margin-top: 6px;
    opacity: 0.8;
}

/* Question */
.quiz-question-container {
    padding: 28px 24px;
}

.quiz-question-number {
    font-size: 0.9rem;
    color: #888;
    font-weight: 600;
    margin-bottom: 10px;
}

.quiz-question-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.7;
    color: #222;
    margin-bottom: 24px;
    min-height: 40px;
}

/* Options */
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.quiz-option:hover {
    border-color: #302b63;
    background: #f0eeff;
}

.quiz-option.selected {
    border-color: #302b63;
    background: #eee8ff;
}

.quiz-option input {
    display: none;
}

.quiz-option-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8e8e8;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.quiz-option.selected .quiz-option-letter {
    background: #302b63;
    color: #fff;
}

.quiz-option-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Navigation */
.quiz-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid #eee;
    background: #fafafa;
    gap: 10px;
}

.quiz-nav-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    color: #555;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quiz-nav-btn:hover:not(:disabled) {
    border-color: #302b63;
    color: #302b63;
}

.quiz-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quiz-nav-btn-primary {
    background: #302b63;
    color: #fff;
    border-color: #302b63;
}

.quiz-nav-btn-primary:hover:not(:disabled) {
    background: #24243e;
    color: #fff;
}

.quiz-nav-btn-submit {
    background: #27ae60;
    color: #fff;
    border-color: #27ae60;
}

.quiz-nav-btn-submit:hover {
    background: #219a52;
    color: #fff !important;
    border-color: #219a52 !important;
}

.quiz-nav-dots {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 300px;
}

.quiz-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-dot.answered {
    background: #302b63;
}

.quiz-dot.current {
    background: #f39c12;
    transform: scale(1.3);
}

/* Confirm Modal */
.quiz-confirm-btns {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.quiz-cancel-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    color: #555;
}

.quiz-confirm-btns .quiz-submit-btn {
    flex: 1;
    background: #e74c3c;
}

/* ---- RESULT PAGE ---- */
.quiz-result-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-result-card {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 460px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.quiz-result-heading {
    font-size: 1.6rem;
    font-weight: 800;
    color: #302b63;
    margin-bottom: 28px;
}

/* Circular Score */
.quiz-result-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin: 0 auto 28px;
    position: relative;
    background: conic-gradient(
        var(--score-color) calc(var(--score-pct) * 1%),
        #e8e8e8 calc(var(--score-pct) * 1%)
    );
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-result-circle-inner {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-result-pct {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--score-color);
}

/* Result Details */
.quiz-result-details {
    text-align: right;
    margin-bottom: 28px;
}

.quiz-result-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.quiz-result-label {
    color: #888;
    font-weight: 600;
    font-size: 0.95rem;
}

.quiz-result-value {
    font-weight: 700;
    color: #333;
    font-size: 0.95rem;
}

.quiz-result-actions .quiz-submit-btn {
    max-width: 280px;
    margin: 0 auto;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
    .quiz-lobby-title {
        font-size: 1.8rem;
    }

    .quiz-cards {
        flex-direction: column;
        align-items: center;
    }

    .quiz-card {
        width: 100%;
        max-width: 320px;
    }

    .quiz-question-container {
        padding: 20px 16px;
    }

    .quiz-nav {
        padding: 12px 16px;
    }

    .quiz-nav-dots {
        display: none;
    }

    .quiz-result-card {
        padding: 28px 20px;
    }
}
