/* أنماط عامة */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --accent: #4895ef;
    --light: #f8f9fa;
    --dark: #212529;
    --success: #4cc9f0;
    --correct: #4CAF50;
    --incorrect: #F44336;
    --danger: #f72585;
    --warning: #f8961e;
    --gray: #6c757d;
    --transition: all 0.3s ease;
    --explanation-bg: #f8f9fa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    padding-top: 80px; /* لتعويض الشريط العلوي الثابت */
}

/* الشريط العلوي */
.top-bar {
    display: none;
    width: 100%;
    background: linear-gradient(135deg, #3a0ca3 0%, #4361ee 100%);
    color: white;
    padding: 10px 20px;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.exam-screen .top-bar {
    display: flex;
}

.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.timer {
    background-color: #212529;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
}

.flag-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.flag-button:hover {
    transform: scale(1.1);
}

.image-display-button, 
.calculator-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.image-display-button:hover,
.calculator-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* حاوية الاختبار الرئيسية */
.quiz-container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* شاشة البداية */
.start-screen {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
}

.start-screen h1 {
    color: var(--primary-dark);
    margin-bottom: 1rem;
    font-size: 2.5rem;
}

.start-screen p {
    color: var(--gray);
    margin-bottom: 2rem;
    font-size: 1.2rem;
    max-width: 600px;
}

/* شاشة القواعد */
.rules-screen {
    padding: 3rem;
}

.rules-screen h2 {
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.rules-list {
    margin-bottom: 2rem;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--light);
    border-radius: 8px;
    transition: var(--transition);
}

.rule-item:hover {
    transform: translateX(5px);
}

/* شاشة الامتحان */
.exam-screen {
    position: relative;
    padding: 2rem;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
}

.question-container {
    flex-grow: 1;
    margin: 1.5rem 0;
    padding: 2rem;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-left: 5px solid var(--primary);
    display: flex;
    flex-direction: column;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    line-height: 1.7;
    color: #2d3748;
    padding-bottom: 1rem;
    border-bottom: 2px solid #edf2f7;
    white-space: pre-line;
}

.question-image {
    max-width: 100%;
    max-height: 350px;
    border-radius: 12px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.answers-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
    margin: 2rem 0;
}

.answer-option {
    padding: 1.2rem 1.5rem;
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
    line-height: 1.6;
    color: #4a5568;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.answer-option:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.answer-option.selected {
    background-color: #ebf8ff;
    border-color: #90cdf4;
    color: #2b6cb0;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.2);
}

.answer-option.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: #3182ce;
}

/* صندوق الشرح */
.explanation-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--explanation-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    animation: fadeIn 0.5s ease;
}

.explanation-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}

.explanation-content {
    font-size: 1rem;
    line-height: 1.7;
    white-space: pre-line;
}

/* أزرار التنقل */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: rgba(67, 97, 238, 0.1);
}

/* شاشة النتائج */
.results-screen {
    text-align: center;
    padding: 3rem;
}

.results-screen h2 {
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.score-display {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 2rem 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    margin: 2rem 0;
    gap: 1rem;
}

.stat-box {
    padding: 1.5rem;
    border-radius: 10px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.correct-stat {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--correct);
}

.incorrect-stat {
    background-color: rgba(244, 67, 54, 0.1);
    color: var(--incorrect);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.result-items-container {
    margin-top: 2rem;
}

.result-item {
    background-color: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-align: left;
}

.result-question {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
    white-space: pre-line;
}

.user-answer {
    padding: 0.8rem;
    margin: 0.3rem 0;
    border-radius: 8px;
    background-color: #f8f9fa;
    font-weight: 500;
}

.user-answer.correct {
    background-color: rgba(76, 175, 80, 0.15);
    border-left: 4px solid var(--correct);
    color: var(--correct);
}

.user-answer.incorrect {
    background-color: rgba(244, 67, 54, 0.15);
    border-left: 4px solid var(--incorrect);
    color: var(--incorrect);
}

.correct-answer {
    background-color: rgba(76, 175, 80, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    color: var(--correct);
    border-left: 4px solid var(--correct);
}

/* تأثيرات الحركة */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* التكيف مع الشاشات الصغيرة */
@media (max-width: 768px) {
    body {
        padding: 1rem;
        padding-top: 70px;
    }
    
    .quiz-container {
        border-radius: 10px;
    }
    
    .start-screen, .rules-screen, .exam-screen {
        padding: 1.5rem;
    }
    
    .question-text {
        font-size: 1.3rem;
    }
    
    .answer-option {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .result-stats {
        flex-direction: column;
    }
    
    .top-bar {
        padding: 8px 10px;
    }
    
    .top-bar-left, .top-bar-right {
        gap: 10px;
    }
    
    .timer {
        font-size: 0.9rem;
        padding: 0.3rem 0.8rem;
    }
    
    .image-display-button, 
    .calculator-button {
        font-size: 0.8rem;
        padding: 4px 8px;
    }
    
    .score-display {
        font-size: 2.5rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
}