/* Quiz Frontend Styles with Arabic Font Support */

/* Import Arabic-friendly fonts */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;600;700&family=Cairo:wght@300;400;500;600;700&display=swap');

/* Root variables for consistent styling */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --border-color: #e0e0e0;
    --text-color: #333;
    --text-muted: #666;
    --border-radius: 12px;
    --box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Base styling with Arabic font support */
.quiz-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    color: var(--text-color);
}

/* Mixed content support (Arabic + English) */
.quiz-container * {
    font-family: inherit;
}

.quiz-container .english {
    direction: ltr;
    text-align: left;
}

/* Error and Debug Styles */
.quiz-error {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 20px 0;
    color: #c62828;
    font-weight: 500;
    text-align: center;
}

.quiz-error p {
    margin: 0;
    font-size: 16px;
}

.quiz-debug {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    padding: 15px;
    margin: 10px 0;
    font-size: 12px;
    color: #333;
    direction: ltr;
    text-align: left;
    font-family: 'Courier New', monospace;
}

/* Enhanced Quiz Information Header */
.quiz-info-header {
    background: var(--primary-gradient);
    color: white;
    padding: 40px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
    position: relative;
    overflow: hidden;
}

.quiz-info-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.05)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.05)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.03)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.quiz-info-header * {
    position: relative;
    z-index: 1;
}

.quiz-info-header .quiz-title {
    margin: 0 0 20px 0;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    line-height: 1.2;
}

.quiz-description {
    text-align: center;
    margin-bottom: 30px;
    font-size: 18px;
    opacity: 0.95;
    line-height: 1.5;
    font-weight: 400;
}

.quiz-meta-info {
    background: rgba(255,255,255,0.15);
    border-radius: var(--border-radius);
    padding: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.quiz-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.meta-item {
    display: flex;
    flex-direction: column;
    text-align: center;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    transition: var(--transition);
}

.meta-item:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.meta-item.chapters-item {
    grid-column: 1 / -1;
    text-align: right;
}

.meta-item.chapters-item .meta-value {
    text-align: right;
    line-height: 1.8;
    white-space: pre-line;
}

.meta-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
    text-transform: none;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}

.meta-value {
    font-size: 18px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Difficulty badges with Arabic support */
.meta-value.difficulty-beginner,
.difficulty-badge.difficulty-beginner {
    color: #4ade80;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.meta-value.difficulty-intermediate,
.difficulty-badge.difficulty-intermediate {
    color: #fbbf24;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.meta-value.difficulty-advanced,
.difficulty-badge.difficulty-advanced {
    color: #f97316;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.meta-value.difficulty-expert,
.difficulty-badge.difficulty-expert {
    color: #ef4444;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.meta-value.difficulty-,
.difficulty-badge.difficulty- {
    color: rgba(255,255,255,0.8);
    font-style: italic;
}

/* Subject Details Styles */
.subject-details {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
}

.subject-header {
    background: var(--primary-gradient);
    color: white;
    padding: 50px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.subject-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.05)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
}

.subject-header * {
    position: relative;
    z-index: 1;
}

.subject-title {
    margin: 0 0 25px 0;
    font-size: 36px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.subject-description {
    font-size: 18px;
    line-height: 1.7;
    opacity: 0.95;
    font-weight: 400;
}

/* Enhanced section styling */
.academic-info-section,
.test-details-section,
.chapters-section,
.available-tests-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 35px;
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
}

.academic-info-section h3,
.test-details-section h3,
.chapters-section h3,
.available-tests-section h3 {
    color: var(--text-color);
    margin-bottom: 25px;
    font-size: 26px;
    font-weight: 700;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 15px;
    text-align: right;
}

.academic-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.info-item {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 10px;
    border-right: 4px solid var(--primary-color);
    transition: var(--transition);
}

.info-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.info-label {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.info-value {
    font-size: 18px;
    color: var(--text-color);
    font-weight: 600;
}

.test-details-content,
.chapters-list {
    background: var(--light-bg);
    padding: 25px;
    border-radius: 10px;
    border-right: 4px solid var(--primary-color);
    line-height: 1.8;
}

.chapters-ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapters-ul li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-right: 30px;
    font-size: 16px;
    line-height: 1.6;
}

.chapters-ul li:before {
    content: "📚";
    position: absolute;
    right: 0;
    font-size: 18px;
}

.chapters-ul li:last-child {
    border-bottom: none;
}

/* Timer Styles with Arabic support */
.quiz-timer {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    padding: 25px;
    text-align: center;
    margin-bottom: 30px;
    border-radius: var(--border-radius);
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    position: relative;
    overflow: hidden;
}

.quiz-timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.quiz-timer.time-up {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.timer-label {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
    opacity: 0.95;
    font-weight: 500;
}

.time-display {
    font-size: 32px;
    font-weight: 900;
    color: inherit;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

/* Question Styles */
.question-block {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.question-block:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.question-title {
    color: var(--text-color);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 25px;
    line-height: 1.5;
    text-align: right;
}

.choices-list {
    margin: 25px 0;
}

.choice-label {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 12px;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    direction: rtl;
}

.choice-label:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    transform: translateX(-5px);
}

.choice-label input[type="radio"] {
    margin-left: 15px;
    transform: scale(1.3);
    accent-color: var(--primary-color);
}

.choice-text {
    flex: 1;
    font-size: 17px;
    line-height: 1.5;
    font-weight: 500;
    color:#000 !important;
}

.choice-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    border: 2px solid transparent;
    transition: var(--transition);
}

/* Enhanced Feedback Styles */
.choice-label.correct {
    background: #d4edda;
    border-color: var(--success-color);
    color: #155724;
}

.choice-label.correct .choice-indicator {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.choice-label.correct .choice-indicator::after {
    content: "✓";
}

.choice-label.incorrect {
    background: #f8d7da;
    border-color: var(--danger-color);
    color: #721c24;
}

.choice-label.incorrect .choice-indicator {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.choice-label.incorrect .choice-indicator::after {
    content: "✗";
}

/* Question Notes */
.question-notes {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    font-size: 15px;
    color: #856404;
    line-height: 1.6;
    border-right: 4px solid #f39c12;
}

.question-feedback {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
}

/* Enhanced Submit Button */
.quiz-submit-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 18px 40px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    margin: 40px 0;
    width: 100%;
    max-width: 250px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.quiz-submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: var(--transition);
}

.quiz-submit-btn:hover:not(:disabled)::before {
    left: 100%;
}

.quiz-submit-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.quiz-submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Responsive Design for Arabic text */
@media (max-width: 768px) {
    .quiz-container,
    .subject-details {
        padding: 15px;
        font-size: 15px;
    }

    .quiz-info-header,
    .subject-header {
        padding: 25px;
    }

    .quiz-info-header .quiz-title,
    .subject-title {
        font-size: 26px;
    }

    .quiz-description,
    .subject-description {
        font-size: 16px;
    }

    .quiz-meta-grid,
    .academic-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .meta-item {
        padding: 12px;
    }

    .question-block {
        padding: 20px;
    }

    .question-title {
        font-size: 18px;
    }

    .choice-label {
        padding: 12px 15px;
        margin-bottom: 10px;
    }

    .choice-text {
        font-size: 16px;
    }

    .choice-label input[type="radio"] {
        margin-left: 10px;
        transform: scale(1.2);
    }

    .academic-info-section,
    .test-details-section,
    .chapters-section,
    .available-tests-section {
        padding: 25px;
    }

    .academic-info-section h3,
    .test-details-section h3,
    .chapters-section h3,
    .available-tests-section h3 {
        font-size: 22px;
    }
}