/* ============================================
   امتحان المفعول المطلق - ملف التنسيقات
   الصف الخامس الابتدائي - الترم الثاني
   ============================================ */

/* --- الإعدادات الأساسية --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #60a5fa;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.2);
}

html, body {
    font-family: 'Cairo', 'Amiri', sans-serif;
    background: var(--gradient-1);
    min-height: 100vh;
    color: var(--dark);
    direction: rtl;
    overflow-x: hidden;
    line-height: 1.6;
}

body {
    padding: 20px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- الشاشات --- */
.screen {
    display: none;
    width: 100%;
    max-width: 900px;
    animation: fadeIn 0.6s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    background: var(--white);
    border-radius: 25px;
    padding: 40px 30px;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary), var(--primary));
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* --- شاشة البداية --- */
.start-container {
    text-align: center;
}

.header-decoration {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.star {
    font-size: 24px;
    color: var(--accent);
    animation: twinkle 2s ease-in-out infinite;
}

.star:nth-child(2) { animation-delay: 0.3s; }
.star:nth-child(3) { animation-delay: 0.6s; }

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.logo-box {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    background: var(--gradient-1);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    animation: float 3s ease-in-out infinite;
    transform: rotate(-5deg);
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.logo-icon {
    font-size: 60px;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--dark);
    margin-bottom: 15px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle-box {
    margin-bottom: 30px;
}

.subtitle {
    font-size: 1.3rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 5px;
}

.grade {
    font-size: 1.1rem;
    color: var(--gray);
    font-weight: 600;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 30px 0;
}

.info-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 20px 15px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.info-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.info-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.info-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
}

.info-label {
    font-size: 0.95rem;
    color: var(--gray);
    font-weight: 600;
    margin-top: 5px;
}

.student-info {
    margin: 25px 0;
    text-align: right;
}

.student-info label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 10px;
}

.label-icon {
    font-size: 1.3rem;
}

.student-info input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.1rem;
    font-family: 'Cairo', sans-serif;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    text-align: right;
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
    background: #f8fafc;
}

.student-info input:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.instructions {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 20px 25px;
    border-radius: 15px;
    margin: 25px 0;
    text-align: right;
    border-right: 5px solid var(--accent);
}

.instructions h3 {
    color: #92400e;
    font-size: 1.2rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    padding: 6px 0;
    padding-right: 25px;
    position: relative;
    color: #78350f;
    font-weight: 500;
}

.instructions li::before {
    content: '◆';
    position: absolute;
    right: 0;
    color: var(--accent);
    font-weight: bold;
}

/* --- الأزرار --- */
.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 400px;
    height: 400px;
}

.btn-primary {
    background: var(--gradient-1);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--gradient-3);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-large {
    padding: 18px 50px;
    font-size: 1.3rem;
    margin-top: 20px;
}

.btn-arrow {
    transition: transform 0.3s ease;
}

.btn:hover .btn-arrow {
    transform: translateX(-5px);
}

/* --- شاشة الامتحان --- */
.quiz-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.student-badge, .timer-badge, .score-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 15px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.student-badge {
    background: var(--gradient-1);
}

.timer-badge {
    background: var(--gradient-2);
}

.score-badge {
    background: var(--gradient-4);
}

.badge-icon {
    font-size: 1.2rem;
}

.timer-badge.warning {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.progress-container {
    margin-bottom: 30px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--dark);
}

.progress-bar {
    height: 12px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: progress-shine 2s linear infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* --- منطقة السؤال --- */
.question-area {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 20px;
    padding: 30px 25px;
    margin-bottom: 20px;
    position: relative;
    border: 2px solid #e2e8f0;
}

.question-number-badge {
    position: absolute;
    top: -20px;
    right: 25px;
    width: 50px;
    height: 50px;
    background: var(--gradient-1);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    box-shadow: var(--shadow-md);
}

.question-type {
    display: inline-block;
    background: var(--accent);
    color: var(--white);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 15px;
    margin-top: 10px;
}

.question-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 25px;
    line-height: 1.8;
    font-family: 'Amiri', 'Cairo', serif;
}

.question-text .highlight {
    color: var(--primary);
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 900;
}

.options-container {
    display: grid;
    gap: 12px;
}

.option {
    background: var(--white);
    border: 2px solid #e2e8f0;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: right;
    font-family: 'Amiri', 'Cairo', serif;
    color: var(--dark);
}

.option-letter {
    width: 35px;
    height: 35px;
    background: var(--light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: var(--primary);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.option:hover:not(.disabled) {
    border-color: var(--primary);
    background: #eff6ff;
    transform: translateX(-5px);
}

.option:hover:not(.disabled) .option-letter {
    background: var(--primary);
    color: var(--white);
}

.option.selected {
    border-color: var(--primary);
    background: #dbeafe;
}

.option.correct {
    border-color: var(--success);
    background: #dcfce7;
    color: #14532d;
}

.option.correct .option-letter {
    background: var(--success);
    color: var(--white);
}

.option.wrong {
    border-color: var(--danger);
    background: #fee2e2;
    color: #7f1d1d;
    animation: shake 0.5s ease;
}

.option.wrong .option-letter {
    background: var(--danger);
    color: var(--white);
}

.option.disabled {
    cursor: not-allowed;
    pointer-events: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.feedback {
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    display: none;
    animation: fadeIn 0.4s ease;
}

.feedback.show {
    display: block;
}

.feedback.correct-feedback {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #14532d;
    border-right: 5px solid var(--success);
}

.feedback.wrong-feedback {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #7f1d1d;
    border-right: 5px solid var(--danger);
}

.feedback-title {
    font-size: 1.15rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-explanation {
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.7;
    color: inherit;
}

.quiz-footer {
    display: flex;
    justify-content: left;
    margin-top: 20px;
}

/* --- شاشة النتيجة --- */
.result-container {
    text-align: center;
}

.result-header {
    margin-bottom: 25px;
}

.result-icon {
    font-size: 80px;
    margin-bottom: 15px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.result-container h2 {
    font-size: 2.2rem;
    color: var(--dark);
    margin-bottom: 8px;
    font-weight: 900;
}

.result-container #result-subtitle {
    color: var(--gray);
    font-size: 1.1rem;
    font-weight: 600;
}

.result-name {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    padding: 15px 25px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 1.15rem;
    color: var(--dark);
    display: inline-block;
}

.result-name strong {
    color: var(--primary);
    font-weight: 900;
}

.score-display {
    margin: 30px 0;
    display: flex;
    justify-content: center;
}

.score-circle {
    position: relative;
    width: 220px;
    height: 220px;
}

.score-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 15;
}

.score-progress {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 15;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 2s ease;
}

.score-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-value {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
}

.score-total {
    font-size: 1.1rem;
    color: var(--gray);
    font-weight: 700;
    margin: 5px 0;
}

.score-percent {
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: 900;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 30px 0;
}

.stat-box {
    padding: 20px 15px;
    border-radius: 15px;
    text-align: center;
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.stat-correct {
    background: var(--gradient-4);
}

.stat-wrong {
    background: var(--gradient-2);
}

.stat-grade {
    background: var(--gradient-3);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.stat-label {
    font-size: 0.95rem;
    margin-top: 5px;
    font-weight: 600;
    opacity: 0.95;
}

/* --- منطقة المراجعة --- */
.review-section {
    margin-top: 30px;
    text-align: right;
}

.review-section h3 {
    font-size: 1.4rem;
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 900;
}

.review-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafc;
    border-radius: 15px;
}

.review-item {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border-right: 5px solid var(--gray);
}

.review-item.correct-item {
    border-right-color: var(--success);
}

.review-item.wrong-item {
    border-right-color: var(--danger);
}

.review-question {
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 10px;
    font-size: 1.05rem;
    font-family: 'Amiri', 'Cairo', serif;
}

.review-answer {
    padding: 8px 12px;
    border-radius: 8px;
    margin: 5px 0;
    font-size: 0.95rem;
    font-family: 'Amiri', 'Cairo', serif;
}

.your-answer.correct-ans {
    background: #dcfce7;
    color: #14532d;
}

.your-answer.wrong-ans {
    background: #fee2e2;
    color: #7f1d1d;
}

.correct-answer {
    background: #dbeafe;
    color: #1e3a8a;
}

.review-explanation {
    background: #fef3c7;
    color: #78350f;
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 0.93rem;
    font-weight: 500;
    line-height: 1.6;
}

/* شريط تمرير مخصص */
.review-container::-webkit-scrollbar {
    width: 8px;
}

.review-container::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.review-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 25px;
}

/* --- تنبيه الحماية --- */
.protection-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: var(--danger);
    color: var(--white);
    padding: 15px 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    transition: transform 0.4s ease;
    font-weight: 700;
    font-size: 1.05rem;
}

.protection-alert.show {
    transform: translateX(-50%) translateY(0);
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-icon {
    font-size: 1.5rem;
}

/* --- التصميم المتجاوب --- */
@media (max-width: 768px) {
    body {
        padding: 10px 5px;
    }

    .container {
        padding: 25px 18px;
        border-radius: 20px;
    }

    .main-title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .grade {
        font-size: 0.95rem;
    }

    .logo-box {
        width: 90px;
        height: 90px;
    }

    .logo-icon {
        font-size: 45px;
    }

    .info-cards {
        gap: 8px;
    }

    .info-card {
        padding: 15px 8px;
    }

    .info-icon {
        font-size: 24px;
    }

    .info-value {
        font-size: 1.5rem;
    }

    .info-label {
        font-size: 0.8rem;
    }

    .quiz-header {
        gap: 6px;
    }

    .student-badge, .timer-badge, .score-badge {
        padding: 10px 8px;
        font-size: 0.8rem;
        flex-direction: column;
        gap: 4px;
    }

    .badge-icon {
        font-size: 1rem;
    }

    .question-text {
        font-size: 1.15rem;
    }

    .option {
        padding: 13px 15px;
        font-size: 1rem;
    }

    .option-letter {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .btn-large {
        padding: 15px 35px;
        font-size: 1.1rem;
    }

    .score-circle {
        width: 180px;
        height: 180px;
    }

    .score-value {
        font-size: 2.8rem;
    }

    .result-container h2 {
        font-size: 1.7rem;
    }

    .result-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-box {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px 20px;
    }

    .stat-icon {
        font-size: 1.8rem;
        margin: 0;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .review-item {
        padding: 15px;
    }

    .review-question {
        font-size: 0.95rem;
    }

    .instructions {
        padding: 15px 18px;
    }

    .instructions h3 {
        font-size: 1.05rem;
    }

    .instructions li {
        font-size: 0.92rem;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 1.5rem;
    }

    .question-number-badge {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: -18px;
    }

    .question-area {
        padding: 25px 18px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}

/* --- الطباعة --- */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
    }

    .btn, .result-actions {
        display: none;
    }

    .screen {
        display: block !important;
    }

    #start-screen, #quiz-screen {
        display: none !important;
    }
}
