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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a; /* Solid Text Color */
    --text-muted: #475569; /* Solid Text Color */
    --border: #e2e8f0;
    --success: #10b981;
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

/* Base Styles */
.iep-dashboard-container, .iep-exam-container {
    font-family: 'Cairo', sans-serif !important;
    direction: rtl;
    background: var(--bg-color);
    color: var(--text-main);
    padding: 30px;
    border-radius: 16px;
    min-height: 80vh;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

/* ---------------- TEACHER DASHBOARD ---------------- */
.iep-dashboard-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.iep-dashboard-header h2 {
    font-size: 32px !important;
    font-weight: 800 !important;
    color: var(--primary) !important;
    margin: 0 0 5px 0 !important;
}

.iep-dashboard-header p {
    color: var(--text-muted);
    font-size: 16px;
    margin: 0;
}

.iep-dashboard-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.iep-sidebar {
    width: 260px;
    background: #ffffff;
    padding: 20px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    position: sticky;
    top: 20px;
}

.iep-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.iep-sidebar ul li {
    margin-bottom: 8px;
}

.iep-sidebar ul li a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-size: 16px;
}

.iep-sidebar ul li a svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.iep-sidebar ul li a:hover, .iep-sidebar ul li a.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
    transform: translateX(-5px);
}

.iep-main-area {
    flex: 1;
    background: #ffffff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.iep-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.iep-stat-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 25px;
    border-radius: 16px;
    text-align: right;
    border: 1px solid #bbf7d0;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.iep-stat-card:hover {
    transform: translateY(-5px);
}

.iep-stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
}

.iep-stat-card h4 {
    margin: 0 0 10px 0;
    color: #166534;
    font-size: 18px;
    font-weight: 700;
}

.iep-stat-card span {
    font-size: 36px;
    font-weight: 800;
    color: #15803d;
    display: block;
}

.iep-table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
}

.iep-table-modern th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    padding: 15px;
    text-align: right;
    border-bottom: 2px solid var(--border);
}

.iep-table-modern td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-weight: 600;
}

.iep-table-modern tr:hover td {
    background: #f1f5f9;
}

.iep-btn-preview {
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s ease;
    display: inline-block;
}

.iep-btn-preview:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

/* ---------------- STUDENT EXAM VIEW ---------------- */
.iep-exam-container {
    background: url('data:image/svg+xml;utf8,<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse"><path d="M 40 0 L 0 0 0 40" fill="none" stroke="%23e2e8f0" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grid)"/></svg>') var(--bg-color);
    padding: 0;
    position: relative;
}

.iep-exam-header {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    border-radius: 16px 16px 0 0;
}

.iep-exam-header h2 {
    font-size: 24px;
    color: var(--text-main);
    margin: 0;
    font-weight: 800;
}

.iep-timer {
    background: var(--primary);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(37,99,235,0.2);
}

.iep-exam-body {
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
}

.iep-question-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease;
}

.iep-question-card:hover {
    transform: translateY(-2px);
}

.iep-question-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 25px;
    line-height: 1.6;
}

.iep-question-image {
    text-align: center;
    margin-bottom: 20px;
}

.iep-question-image img {
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.iep-choices {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.iep-choice-label {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.iep-choice-label:hover {
    border-color: #93c5fd;
    background: #f0fdf4; /* Subtle green/blue hint on hover */
    transform: translateX(-5px);
}

.iep-choice-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    margin-left: 15px;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.iep-choice-label input[type="radio"]:checked {
    border-color: var(--primary);
}

.iep-choice-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
}

.iep-choice-label:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}

.iep-exam-footer {
    padding: 20px 40px 40px;
    text-align: left; /* Button on the left in RTL */
    max-width: 800px;
    margin: 0 auto;
}

.iep-btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: #fff;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: 800;
    font-family: 'Cairo', sans-serif;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(37,99,235,0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.iep-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(37,99,235,0.4);
}

.iep-btn-primary:active {
    transform: translateY(1px);
}

/* Success Result Popup Styling */
#iep-exam-result {
    margin: 40px auto;
    max-width: 500px;
    padding: 40px;
    background: #ffffff;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    border: 2px solid var(--success);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#iep-exam-result h3 {
    color: var(--success);
    font-size: 28px;
    font-weight: 800;
    margin-top: 0;
}

#iep-exam-result p {
    font-size: 20px;
    color: var(--text-main);
    font-weight: 700;
}

#iep-score-display {
    font-size: 48px;
    color: var(--primary);
    display: block;
    margin-top: 15px;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

/* Math rendering adjustments */
.math-tex {
    direction: ltr; /* Ensure math renders left to right */
    display: inline-block;
}
