:root {
    --primary-blue: #2980b9; 
    --light-gray-bg: #f8f9fa; 
    --body-bg: #f4f9f9; 
    --card-bg: rgba(255, 255, 255, 0.6); 
    --text-dark: #2c3e50; 
    --text-muted: #7f8c8d; 
    --border-color: rgba(0, 0, 0, 0.1);
    --success-green: #27ae60;
    --success-bg: rgba(39, 174, 96, 0.15);
    --fail-red: #c0392b;
    --fail-bg: rgba(192, 57, 43, 0.15);
    --high-score-color: #16a085;
    --medium-score-color: #f39c12;
    --low-score-color: #d35400;
    --card-shadow: 0 8px 25px rgba(0, 0, 0, 0.05);
    --card-hover-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Cairo', sans-serif;
    margin: 0;
    padding: 1.5rem;
    direction: rtl;
    color: var(--text-dark); 
    background-color: var(--body-bg); 
    background-image: 
        radial-gradient(circle at 100% 0%, rgba(41, 128, 185, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 0% 100%, rgba(22, 160, 133, 0.1) 0%, transparent 30%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.page-header {
    display: flex;
    justify-content: flex-start;
    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;
    background-color: var(--card-bg);
}

.back-link:hover {
    background-color: var(--light-gray-bg);
    color: var(--text-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.back-link svg {
    width: 0.7em;
    transform: scaleX(1);
}

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

.search-page-container {
    text-align: center;
    padding: 4rem 1rem;
    background-color: var(--card-bg);
    border-radius: 2rem;
    box-shadow: var(--card-shadow);
}
.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 20px 0 130px; 
    border-radius: 50px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    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;
    left: 5px; 
    top: 50%;
    transform: translateY(-50%);
    height: 50px;
    background: var(--primary-blue);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.5rem; 
    font-family: 'Changa', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}
.search-button:hover { background-color: #005a9e; }
.search-icon { width: 18px; height: 18px; fill: #fff; } 

.student-summary-card {
    background-color: var(--card-bg);
    border-radius: 2.5rem;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    text-align: center;
    margin-bottom: 2rem;
}
.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;
}
.progress-circle-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}
.progress-ring {
    transform: rotate(-90deg);
}
.progress-ring-circle-bg {
    fill: none;
    stroke: var(--light-gray-bg);
}
.progress-ring-circle {
    fill: none;
    stroke: var(--primary-blue); 
    stroke-linecap: round;
    stroke-dasharray: 314;
    transition: stroke-dashoffset 1.5s ease-out;
}
.percentage-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    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;
    margin: 0 auto;
}
.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); }

.additional-info-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background-color: var(--light-gray-bg);
    border-radius: 1rem;
}
.info-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
}
.info-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.subjects-container {
    margin-bottom: 2rem;
    text-align: center;
}
.subjects-title {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 2.5rem;
    position: relative;
    display: inline-block;
}
.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: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    text-align: right;
}
.subject-card {
    background-color: var(--card-bg);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUpFadeIn 0.6s ease-out forwards;
}
.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-hover-shadow);
}
@keyframes slideUpFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.subject-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.subject-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 1rem;
    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); width: 28px; height: 28px; }
.subject-info { display: flex; flex-direction: column; gap: 0.25rem; flex-grow: 1; }
.subject-name { font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.subject-status-badge {
    padding: 4px 12px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.8rem;
    width: fit-content;
}
.subject-status-badge.status-success { background-color: var(--success-bg); color: var(--success-green); }
.subject-status-badge.status-fail { background-color: var(--fail-bg); color: var(--fail-red); }
.subject-grade {
    font-weight: 900;
    font-size: 1.2rem;
    text-align: left;
    flex-shrink: 0;
}
.student-grade { font-size: 2rem; color: var(--text-dark); }
.max-grade { color: var(--text-muted); }
.progress-bar-container {
    height: 8px;
    width: 100%;
    background-color: var(--light-gray-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1.5s ease-out;
}
.progress-bar-fill.high { background-color: var(--success-green); }
.progress-bar-fill.medium { background-color: var(--medium-score-color); }
.progress-bar-fill.low { background-color: var(--low-score-color); }

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    margin: 2rem auto;
    color: var(--text-muted);
    font-weight: 700;
    text-align: center;
    box-sizing: border-box;
    overflow: hidden; 
}
.ad-leaderboard {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
}
.ad-rectangle {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    margin-top: 0;
}

.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 (max-width: 768px) {
    body { padding: 1rem; }
    .main-container { padding: 0; }

    .summary-grid { grid-template-columns: 1fr; justify-items: center; }
    .percentage-item { order: -1; }
    .actions-container { flex-direction: column; align-items: center; gap: 0.75rem; }

    .student-name-main { font-size: 1.5rem; }
    .total-grade-main { font-size: 2rem; }
    #countdown-timer h2 { font-size: 1.5rem; }
    .countdown-box .number { font-size: 2.2rem; }
    .countdown-box .label { font-size: 0.8rem; }

    .search-input { height: 55px; padding-right: 15px; padding-left: 70px; font-size: 0.8rem; }
    .search-button { height: 45px; padding: 0 1rem; font-size: 1rem; }
    .search-icon { display: none; } 

    .social-icons-container { bottom: 15px; left: 15px; gap: 10px; }
    .social-icon { width: 50px; height: 50px; }
    .social-icon svg { width: 25px; height: 25px; }
}

@media (max-width: 480px) {

    .student-summary-card, .additional-info-card, .search-page-container, #countdown-timer, .subjects-grid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .seat-number-box { font-size: 1.2rem; padding: 0.5rem 1rem; }
    .status-badge { font-size: 1rem; }
    .subjects-grid { grid-template-columns: 1fr; }
    .subject-name { font-size: 1.1rem; }
    .student-grade { font-size: 1.8rem; }
}

.social-icons-container {
    position: fixed;
    bottom: 25px;
    left: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1000;
}

.social-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    transform: scale(1);
}

.social-icon svg {
    width: 30px;
    height: 30px;
    fill: #ffffff;
}

.social-icon.whatsapp { background-color: #25D366; }
.social-icon.telegram { background-color: #0088cc; }

.social-icon:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.2);
}

.announcement-bar {
    font-family: 'Changa', sans-serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--primary-blue);
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(-45deg, #e7f3ff, #ffffff, #e7f3ff);
    background-size: 400% 400%;
    border-radius: 1rem;
    text-align: center;
    animation: gradient-pulse 5s ease infinite;
}

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

#countdown-timer {
    font-family: 'Changa', sans-serif;
    text-align: center;
    margin: 1.5rem 0;
    padding: 0.5rem;
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

#countdown-timer h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}

#countdown-container {
    display: flex;
    justify-content: center;
    gap: 1.0rem;
    color: var(--text-dark);
}

.countdown-box {
    display: flex;
    flex-direction: column;
}

.countdown-box .number {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.1;
    color: var(--primary-blue);
}

.countdown-box .label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
}

.student-summary-card,
.additional-info-card,
.subject-card,
.search-page-container,
.error-message {
    background: rgba(255, 255, 255, 0.25); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px); 
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.3);
}

.search-page-container {
    padding: 1rem; 
}

.actions-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.action-button {
    font-family: 'Cairo', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-button svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.action-button.print { background-color: #4A5568; }
.action-button.share { background-color: #38A169; }

.action-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.capture-style {
    padding: 2rem;

    background-color: var(--body-bg);
    background-image: 
        radial-gradient(circle at 100% 0%, rgba(41, 128, 185, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 0% 100%, rgba(22, 160, 133, 0.1) 0%, transparent 30%);
    position: relative;
    border-radius: 1.5rem;
}

.congrats-overlay {
    font-family: 'Changa', sans-serif;
    color: var(--text-dark); 
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: none; 
    padding-bottom: 1rem;
}

@media print {

    body * {
        visibility: hidden;
    }
    #result-to-capture, #result-to-capture * {
        visibility: visible;
    }
    #result-to-capture {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .student-summary-card,
    .additional-info-card {
        background: #fff !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

.developer-credit {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background-color: var(--primary-blue);
    color: #ffffff;
    padding: 8px 15px;
    border-radius: 50px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    z-index: 1001; 
    transform: translateY(100px); 
    animation: slide-up-credit 1s 1.5s ease-out forwards; 
}

.developer-credit a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

.developer-credit a:hover {
    color: #f1c40f; 
}

@keyframes slide-up-credit {
    to {
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .developer-credit {
        font-size: 0.8rem;
        bottom: 10px;
        right: 10px;
    }
}

/* --- قسم الاشتراك في قناة الواتساب --- */
.whatsapp-subscribe-section {
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px dashed var(--fail-red);
    border-radius: 1.5rem;
    padding: 1.5rem;
    text-align: center;
    margin-top: -1rem; /* لتقليل المسافة مع الشريط العلوي */
    margin-bottom: 2rem;
}

.urgent-message {
    font-family: 'Changa', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fail-red);
    margin: 0 0 1rem 0;
}

.whatsapp-subscribe-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background-color: #25D366;
    color: #ffffff;
    padding: 1rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: shake 1.5s infinite;
}

.whatsapp-subscribe-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4);
    animation-play-state: paused; /* إيقاف الاهتزاز عند المرور */
}

.whatsapp-subscribe-button svg {
    width: 24px;
    height: 24px;
}

/* حركة الاهتزاز للفت الانتباه */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@media (max-width: 768px) {
    .urgent-message { font-size: 1.2rem; }
    .whatsapp-subscribe-button { font-size: 1rem; padding: 0.8rem 1.5rem; }
}