/* Ultra-Professional Alexandria & Cairo Typography + 100% Fluid Mobile Responsiveness */
:root {
    --font-ar: 'Alexandria', 'Cairo', system-ui, -apple-system, sans-serif;
    --font-en: 'Outfit', sans-serif;

    /* Navy Brand Palette */
    --navy-dark: #070F1E;
    --navy-primary: #0B192C;
    --navy-royal: #1E3E62;
    
    /* Clean Porcelain White */
    --bg-main: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-glass-border: #E2E8F0;

    /* Text Colors */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --text-white: #FFFFFF;

    /* Accents */
    --accent-gold: #D97706;
    --accent-gold-yellow: #FACC15;
    --accent-blue: #2563EB;
    
    --success-emerald: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    
    --warning-amber: #D97706;
    --warning-bg: rgba(217, 119, 6, 0.1);

    --danger-red: #DC2626;
    --danger-bg: rgba(220, 38, 38, 0.1);

    --radius-lg: 16px;
    --radius-md: 12px;

    --transition: all 0.25s ease;
    --shadow-card: 0 4px 20px rgba(11, 25, 44, 0.06);
}

/* Base Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    overflow-y: scroll;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.2rem;
}

/* Simple Navy Navbar */
.navbar {
    background: var(--navy-primary);
    color: var(--text-white);
    padding: 0.85rem 0;
    box-shadow: 0 2px 10px rgba(11, 25, 44, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid var(--accent-gold);
}
.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--accent-gold);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.brand-text h1 {
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    font-weight: 800;
    color: var(--text-white);
    line-height: 1.2;
}
.badge-year {
    font-size: 0.75rem;
    color: #93C5FD;
}

.nav-links {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.nav-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    padding: 0.5rem 0.9rem;
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.nav-btn:hover { color: #FFF; }
.nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #FFF;
}

/* Main Section */
.main-content {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 4rem;
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-top: 1.6rem;
    margin-bottom: 2rem;
}
.hero-dev-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(11, 25, 44, 0.05);
    border: 1px solid var(--navy-primary);
    color: var(--navy-primary);
    padding: 0.4rem 1.2rem;
    border-radius: 30px;
    font-size: clamp(0.78rem, 2.5vw, 0.86rem);
    font-weight: 700;
    margin-bottom: 1rem;
    max-width: 100%;
}
.hero-dev-tag strong {
    color: var(--navy-primary);
    font-family: var(--font-en);
    font-weight: 800;
}

.hero-title {
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    font-weight: 900;
    color: var(--navy-primary);
    margin-bottom: 0.4rem;
    line-height: 1.3;
}
.hero-title span { color: var(--accent-blue); }

.hero-subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2.8vw, 1.05rem);
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 4vw, 1.8rem);
    box-shadow: var(--shadow-card);
}

/* Search Card */
.search-card {
    max-width: 680px;
    margin: 0 auto 2rem;
    border-top: 4px solid var(--navy-primary);
}

.search-mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}
.mode-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--bg-glass-border);
    background: #F1F5F9;
    color: var(--text-secondary);
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.mode-btn.active {
    background: var(--navy-primary);
    color: var(--text-white);
    border-color: var(--navy-primary);
}

/* Input Group & Wrapper */
.input-group {
    display: flex;
    gap: 0.8rem;
    width: 100%;
}

.input-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
}

.input-icon {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--navy-primary);
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 2;
}

.input-wrapper input {
    width: 100%;
    background: #FFFFFF;
    border: 2px solid var(--bg-glass-border);
    border-radius: var(--radius-md);
    padding: 0.95rem 2.8rem 0.95rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: clamp(16px, 4vw, 1.1rem);
    font-weight: 700;
    outline: none;
    transition: var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--navy-primary);
}

.primary-btn {
    background: var(--navy-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0 1.8rem;
    font-family: var(--font-ar);
    font-weight: 800;
    font-size: clamp(0.95rem, 3vw, 1.05rem);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.primary-btn:hover {
    background: var(--navy-royal);
}

/* Suggestions */
.suggestions-box {
    background: #FFFFFF;
    border: 1px solid var(--navy-primary);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(11, 25, 44, 0.15);
}

.suggestion-item {
    padding: 0.8rem 1.1rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-glass-border);
    cursor: pointer;
    gap: 0.5rem;
}
.suggestion-item:hover { background: #F1F5F9; }

.sug-name { font-weight: 700; word-break: break-word; }
.sug-seat { font-family: var(--font-en); color: var(--navy-primary); font-weight: 700; white-space: nowrap; }

/* Result Card */
.result-card {
    max-width: 750px;
    margin: 0 auto;
    background: #FFFFFF;
    border: 2px solid var(--navy-primary);
}

.cert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px dashed var(--bg-glass-border);
    padding-bottom: 1.2rem;
    margin-bottom: 1.5rem;
    gap: 0.8rem;
    flex-wrap: wrap;
}
.cert-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(217, 119, 6, 0.1);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}
.cert-title-group h3 { font-size: clamp(1.05rem, 3.5vw, 1.3rem); font-weight: 800; color: var(--navy-primary); line-height: 1.2; }
.cert-sub { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; display: block; margin-top: 0.1rem; }

.cert-badge {
    padding: 0.5rem 1.4rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    white-space: nowrap;
}
.cert-badge.passed { background: var(--success-bg); color: var(--success-emerald); }
.cert-badge.second-round { background: var(--warning-bg); color: var(--warning-amber); }
.cert-badge.failed { background: var(--danger-bg); color: var(--danger-red); }

/* Info Grid */
.student-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.8rem;
}
.info-box {
    background: #F8FAFC;
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    word-break: break-word;
}

.info-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.info-value { font-size: clamp(1rem, 3vw, 1.15rem); font-weight: 800; }
.name-value { color: var(--navy-primary); }
.rank-value { color: var(--accent-gold); font-family: var(--font-en); }

/* Score Gauge */
.score-visualization-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 1.5rem;
    background: #F1F5F9;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    flex-wrap: wrap;
}

.gauge-wrapper { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: #CBD5E1; stroke-width: 14; }
.gauge-fill { fill: none; stroke: var(--navy-primary); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 1.2s ease; }

.gauge-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.gauge-percentage { font-size: 1.6rem; font-weight: 900; font-family: var(--font-en); color: var(--navy-primary); }
.gauge-label { font-size: 0.72rem; color: var(--text-muted); }

.score-details-card { flex: 1; min-width: 180px; }
.score-num { font-size: clamp(2rem, 6vw, 2.5rem); font-weight: 900; font-family: var(--font-en); color: var(--navy-primary); }
.score-max { font-size: 1rem; color: var(--text-muted); }

.score-bar-container {
    width: 100%;
    height: 12px;
    background: #CBD5E1;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.score-bar-fill { height: 100%; background: var(--navy-primary); border-radius: 10px; transition: width 1.2s ease; }

.cert-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--bg-glass-border);
    flex-wrap: wrap;
}
.secondary-btn {
    background: #F1F5F9;
    border: 1px solid var(--bg-glass-border);
    color: var(--navy-primary);
    padding: 0.75rem 1.4rem;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}
.secondary-btn:hover {
    background: #E2E8F0;
    border-color: var(--navy-primary);
}

/* Leaderboard Rank Badges */
.rank-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 0.9rem;
}
.rank-badge.top-1 { background: #FEF3C7; color: #D97706; border: 2px solid #F59E0B; }
.rank-badge.top-2 { background: #F1F5F9; color: #475569; border: 2px solid #94A3B8; }
.rank-badge.top-3 { background: #FFEDD5; color: #C2410C; border: 2px solid #EA580C; }
.rank-badge.other { background: rgba(11, 25, 44, 0.06); color: var(--navy-primary); }

.text-gold { color: var(--accent-gold); }

/* Distribution Bars Styling (Stats Tab) */
.stats-detail-card {
    margin-top: 1.8rem;
}

.dist-bars-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.2rem;
}

.dist-row {
    background: #F8FAFC;
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: var(--transition);
}

.dist-row:hover {
    border-color: var(--navy-primary);
    box-shadow: 0 4px 15px rgba(11, 25, 44, 0.05);
}

.dist-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: clamp(0.85rem, 2.8vw, 0.95rem);
    font-weight: 700;
    color: var(--navy-primary);
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dist-bar-outer {
    width: 100%;
    height: 14px;
    background: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.dist-bar-inner {
    height: 100%;
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Table */
.section-title { font-size: clamp(1.1rem, 3.5vw, 1.25rem); font-weight: 800; margin-bottom: 1rem; color: var(--navy-primary); }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; text-align: right; min-width: 500px; }
.data-table th, .data-table td { padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--bg-glass-border); }
.data-table th { background: var(--navy-primary); color: #fff; font-weight: 700; font-size: 0.85rem; }
.data-table tbody tr:hover { background: #F1F5F9; }

/* Metrics Dashboard Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
    margin-bottom: 1.8rem;
}

@media (min-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.2rem;
    }
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1.1rem 0.95rem;
    border-radius: var(--radius-lg);
    background: #FFFFFF;
    border: 1px solid var(--bg-glass-border);
    box-shadow: 0 4px 15px rgba(11, 25, 44, 0.04);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(11, 25, 44, 0.08);
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.metric-icon.blue { background: linear-gradient(135deg, #0B192C, #1E3E62); color: #FFFFFF; }
.metric-icon.green { background: linear-gradient(135deg, #059669, #10B981); color: #FFFFFF; }
.metric-icon.orange { background: linear-gradient(135deg, #D97706, #F59E0B); color: #FFFFFF; }
.metric-icon.red { background: linear-gradient(135deg, #DC2626, #EF4444); color: #FFFFFF; }

.metric-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.metric-val {
    font-size: clamp(1.1rem, 3.8vw, 1.45rem);
    font-weight: 900;
    font-family: var(--font-en);
    color: var(--navy-primary);
    line-height: 1.2;
}

.metric-lbl {
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Custom Premium UI Alert Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(11, 25, 44, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1.2rem;
    animation: fadeIn 0.25s ease;
}

.modal-card {
    background: #FFFFFF;
    border-radius: 20px;
    padding: 1.8rem 1.6rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(11, 25, 44, 0.25);
    border: 1px solid var(--bg-glass-border);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.modal-icon-badge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}
.modal-icon-badge.warning { background: rgba(217, 119, 6, 0.12); color: var(--warning-amber); }
.modal-icon-badge.error { background: rgba(220, 38, 38, 0.12); color: var(--danger-red); }
.modal-icon-badge.info { background: rgba(37, 99, 235, 0.12); color: var(--accent-blue); }
.modal-icon-badge.success { background: rgba(5, 150, 105, 0.12); color: var(--success-emerald); }

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--navy-primary);
}

.modal-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-confirm-btn {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.5rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--navy-primary);
    color: #fff;
    padding: 0.85rem 1.6rem;
    border-radius: 30px;
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    pointer-events: none;
}
.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Footer */
.footer {
    background: var(--navy-primary);
    color: #fff;
    padding: 1.8rem 0;
    margin-top: auto;
    text-align: center;
    border-top: 3px solid var(--accent-gold);
}
.footer-dev-badge {
    margin-bottom: 0.4rem;
    font-size: clamp(0.85rem, 2.8vw, 0.95rem);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}
.dev-highlight { color: var(--accent-gold-yellow); font-family: var(--font-en); font-weight: 800; }
.footer p { font-size: 0.85rem; color: #94A3B8; }

/* Fully Responsive Breakpoints & Mobile Keyboard Optimization */
@media (max-width: 640px) {
    .navbar {
        padding: 0.7rem 0;
    }
    .main-content {
        padding-top: 2rem;
        padding-bottom: 6rem;
    }
    .hero-section {
        margin-top: 2.4rem;
        margin-bottom: 2rem;
    }
    .nav-container {
        flex-direction: column;
        gap: 0.65rem;
        text-align: center;
    }
    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
        border-radius: 8px;
    }
    .brand-text h1 {
        font-size: 1.05rem;
    }
    .badge-year {
        font-size: 0.72rem;
    }
    .nav-links {
        justify-content: center;
        width: 100%;
        gap: 0.35rem;
    }
    .nav-btn {
        padding: 0.45rem 0.8rem;
        font-size: 0.82rem;
        border-radius: 20px;
    }
    .input-group {
        flex-direction: column;
        gap: 0.6rem;
    }
    .input-wrapper input {
        padding: 0.85rem 2.8rem 0.85rem 0.8rem;
        font-size: 16px;
    }
    .primary-btn {
        width: 100%;
        padding: 0.85rem;
    }
    .cert-header {
        flex-direction: column;
        text-align: center;
        justify-content: center;
    }
    .score-visualization-row {
        flex-direction: column;
        text-align: center;
    }
    .cert-footer {
        justify-content: center;
    }
    .secondary-btn {
        width: 100%;
        justify-content: center;
    }
    .search-card {
        margin-bottom: 1.5rem;
    }
    .suggestions-box {
        max-height: 200px;
    }
}

@media (max-width: 360px) {
    .container { padding: 0 0.8rem; }
    .glass-card { padding: 0.9rem; }
    .nav-btn { padding: 0.4rem 0.6rem; font-size: 0.78rem; }
}

/* Print Styles */
@media print {
    body { background: #fff !important; color: #000 !important; }
    .navbar, .hero-section, .search-card, .footer, .no-print, .nav-links, .toast-notification, .modal-overlay { display: none !important; }
    .container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
    .result-card { border: 2px solid #000 !important; box-shadow: none !important; margin: 0 auto !important; width: 100% !important; }
    .score-visualization-row { background: #f8fafc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .cert-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
