/* ==========================================================================
   Thanaweya Amma 2026 Results Portal - Premium Stylesheet
   ========================================================================== */

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-gold: #f59e0b;
    --accent-gold-glow: rgba(245, 158, 11, 0.25);
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --font-heading: 'Cairo', sans-serif;
    --font-body: 'Tajawal', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: #f1f5f9;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Navbar */
.navbar {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 0;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 4px 14px var(--accent-gold-glow);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
}

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

.brand-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.theme-toggle-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    transform: rotate(15deg) scale(1.05);
    background: var(--bg-card-hover);
}

/* Hero Section */
.hero-section {
    position: relative;
    padding: 60px 0 40px;
    text-align: center;
    overflow: hidden;
}

.hero-bg-shapes .shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.15;
    z-index: -1;
}

.shape-1 {
    top: -50px;
    right: -50px;
    width: 350px;
    height: 350px;
    background: var(--accent-blue);
}

.shape-2 {
    bottom: -50px;
    left: -50px;
    width: 350px;
    height: 350px;
    background: var(--accent-gold);
}

.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-gold);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.hero-content h2 {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-content h2 {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 650px;
    margin: 0 auto 36px;
}

/* Search Card Wrapper */
.search-card-wrapper {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 720px;
    margin: 0 auto 40px;
    box-shadow: var(--shadow-lg);
}

.search-tabs {
    display: flex;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: var(--radius-md);
    gap: 6px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25 ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 16px 50px 16px 45px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
}

.input-group input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.clear-btn {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
}

.clear-btn:hover {
    color: var(--text-primary);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-card-hover);
}

.sug-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.sug-seat {
    font-size: 0.85rem;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
    color: #fff;
    padding: 16px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 800;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: #fff;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--accent-gold-glow);
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background: var(--bg-card-hover);
}

.search-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Quick Stats Bar */
.quick-stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(8px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-lbl {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Sections Base */
.section-container {
    margin: 40px auto;
}

.results-header {
    margin-bottom: 20px;
}

.results-header h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.students-results-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.students-results-table th, 
.students-results-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.students-results-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.9rem;
}

.students-results-table tbody tr {
    transition: background 0.15s ease;
}

.students-results-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* Single Printable Scorecard Card */
.printable-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.scorecard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.official-seal {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent-gold), #b45309);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
    box-shadow: 0 4px 16px var(--accent-gold-glow);
}

.official-title h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
}

.official-title h3 {
    font-size: 1.1rem;
    color: var(--accent-gold);
    font-weight: 700;
}

.official-title h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.student-status-badge {
    padding: 10px 22px;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
}

.student-status-badge.pass {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--accent-emerald);
}

.student-status-badge.second-round {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--accent-gold);
}

.scorecard-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

.student-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.branch-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--accent-gold);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.branch-select:focus, .branch-select:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.info-value.highlight {
    color: var(--accent-gold);
    font-family: var(--font-heading);
}

/* Grades Table */
.grades-table-wrapper {
    margin-bottom: 28px;
}

.grades-table-wrapper h4 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grades-table {
    width: 100%;
    border-collapse: collapse;
}

.grades-table th, .grades-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
}

.grades-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.progress-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.progress-pill.excellent { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.progress-pill.very-good { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.progress-pill.good { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }

/* Total Summary Card */
.total-summary-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(245, 158, 11, 0.08));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    align-items: center;
}

.total-score-box, .percentage-box, .prediction-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.total-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.total-score-value {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--accent-gold);
}

.percentage-value {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--accent-emerald);
}

.prediction-text {
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 1.05rem;
}

.scorecard-actions {
    display: flex;
    gap: 16px;
    margin-top: 28px;
    justify-content: flex-end;
}

/* Top Achievers Grid */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
}

.top-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.top-student-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.top-student-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-gold);
}

.rank-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 12px var(--accent-gold-glow); }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); }
.rank-3 { background: linear-gradient(135deg, #b45309, #78350f); }
.rank-other { background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-secondary); }

.top-student-info h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.top-student-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.top-score-badge {
    margin-right: auto;
    font-family: var(--font-heading);
    font-weight: 800;
    color: var(--accent-emerald);
    font-size: 1.15rem;
}

/* Top Score & Distribution Cards */
.distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.dist-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(8px);
    transition: transform 0.2s ease;
}

.dist-card:hover {
    transform: translateY(-3px);
}

.dist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dist-range {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
}

.dist-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}

.dist-badge.excellent { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.dist-badge.very-good { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.dist-badge.good { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }
.dist-badge.pass-sub { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.dist-badge.fail { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

.dist-count {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text-primary);
}

.dist-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.dist-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease-in-out;
}

.fill-90 { background: linear-gradient(90deg, #f59e0b, #d97706); }
.fill-80 { background: linear-gradient(90deg, #10b981, #059669); }
.fill-70 { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.fill-60 { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.fill-50 { background: linear-gradient(90deg, #ec4899, #be185d); }
.fill-below50 { background: linear-gradient(90deg, #f43f5e, #be123c); }

.dist-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Footer */
.main-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 30px 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-gold);
}

.copyright {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Print Styles */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .navbar, .hero-section, .no-print, .main-footer, .top-achievers-section, #nameResultsSection {
        display: none !important;
    }
    #singleResultSection {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .printable-card {
        border: 2px solid #000 !important;
        box-shadow: none !important;
        color: #000 !important;
        background: #fff !important;
    }
    .official-seal {
        background: #000 !important;
        color: #fff !important;
    }
}
