/* --- إعدادات عامة وخطوط --- */
:root {
    --primary-blue: #0071C9;
    --light-gray-bg: #f8f9fa;
    --body-bg: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --success-green: #198754;
    --success-bg: #D3FCE1;
    --fail-red: #dc3545;
    --fail-bg: #F5737F;
    --card-shadow: 0 15px 40px rgba(0, 0, 0, 0.07);
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--body-bg);
    margin: 0;
    padding: 1.5rem;
    direction: rtl;
    color: var(--text-dark);
}

.main-container {
    max-width: 900px;
    margin: 0 auto;
}

/* --- رأس الصفحة --- */
.page-header {
    display: flex;
    justify-content: flex-start; /* Changed */
    align-items: center;
    margin-bottom: 2rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-muted);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.back-link:hover {
    background-color: var(--light-gray-bg);
    color: var(--text-dark);
}

.back-link svg {
    width: 0.7em;
    transform: scaleX(1); /* Flipped for RTL */
}

.font-changa {
    font-family: 'Changa', sans-serif;
}

/* --- صفحة البحث الرئيسية --- */
.search-page-container {
    text-align: center;
    padding-top: 4rem;
}
.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--primary-blue);
    margin-bottom: 2rem;
}
.search-container { margin-bottom: 2rem; }
.search-wrapper { position: relative; }
.search-input {
    width: 100%;
    height: 60px;
    padding: 0 70px 0 20px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
    font-family: 'Cairo', sans-serif;
    box-sizing: border-box;
    transition: all 0.2s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 113, 201, 0.15);
}
.search-input::placeholder { color: #BFBFBF; font-weight: 700; }
.search-button {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 65px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.search-icon { width: 24px; height: 24px; fill: var(--primary-blue); }

/* --- بطاقة ملخص النتيجة --- */
.student-summary-card {
    background-color: #fff;
    border-radius: 2.5rem;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    text-align: center;
    margin-bottom: 3rem;
}
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.summary-item { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.summary-label { font-size: 1rem; color: var(--text-muted); font-weight: 700; }
.seat-number-box {
    font-family: 'Changa', sans-serif;
    border: 2px solid black;
    padding: 0.5rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 1.5rem;
    font-weight: 600;
}
.percentage-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 10px solid var(--light-gray-bg);
    border-top-color: var(--primary-blue); /* This creates the progress effect */
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(45deg); /* Start point */
}
.percentage-value {
    transform: rotate(-45deg); /* Counter-rotate text */
    font-size: 1.5rem;
    font-weight: 900;
}
.status-badge {
    padding: 0.5rem 1.5rem;
    border-radius: 0.65rem;
    border: 2px solid black;
    font-weight: 700;
    font-size: 1.2rem;
    width: fit-content; /* Fix for stretching issue */
    margin: 0 auto; /* Center badge in its container */
}
.status-success { background-color: var(--success-bg); }
.status-fail { background-color: var(--fail-bg); }
.student-name-main { font-size: 2rem; font-weight: 900; display: block; margin-bottom: 0.5rem; }
.total-grade-main { font-size: 2.5rem; font-weight: 900; color: var(--text-muted); }
.total-grade-main .student-total-grade { color: var(--primary-blue); }

/* --- قسم درجات المواد --- */
.subjects-container { margin-bottom: 2rem; }
.subjects-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
}
.subjects-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 5%;
    width: 90%;
    height: 6px;
    background-color: rgba(0, 113, 201, 0.2);
    border-radius: 3px;
}
.subjects-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to 1 column for mobile */
    gap: 1.5rem;
}
.subject-card {
    background-color: #fff;
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.subject-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.subject-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 1.25rem;
    background-color: var(--light-gray-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.subject-icon-wrapper svg { color: var(--primary-blue); }
.subject-info { display: flex; flex-direction: column; }
.subject-name { font-size: 1.2rem; font-weight: 700; }
.subject-type { font-size: 0.9rem; color: var(--text-muted); }
.subject-footer { display: flex; justify-content: flex-end; align-items: baseline; }
.subject-grade { font-weight: 900; font-size: 1.2rem; }
.student-grade { font-size: 2.5rem; color: var(--text-dark); }
.max-grade { color: var(--text-muted); }

/* --- رسالة الخطأ --- */
.error-message {
    background-color: var(--fail-bg);
    color: var(--fail-red);
    border: 1px solid var(--fail-red);
    padding: 1.5rem;
    border-radius: 1rem;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 2rem;
}

/* --- تصميم متجاوب --- */
@media (min-width: 640px) {
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns for tablets and up */
    }
}

@media (min-width: 900px) {
    .subjects-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for large screens */
    }
}

@media (max-width: 768px) {
    body { padding: 1rem; }
    .summary-grid { 
        grid-template-columns: 1fr; 
        justify-items: center; /* Center items in mobile view */
    }
    .percentage-item { order: -1; } /* Move percentage to top on mobile */
    .student-name-main { font-size: 1.5rem; }
    .total-grade-main { font-size: 2rem; }
    /* The subjects grid will be 1 column due to the default setting */
}
