/* ========================================
   CSS Variables & Design Tokens
   ======================================== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1f2847;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-modal: #151c2e;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-1: #6366f1;
    /* Indigo */
    --accent-2: #8b5cf6;
    /* Purple */
    --accent-3: #06b6d4;
    /* Cyan */
    --accent-4: #10b981;
    /* Emerald */
    --accent-5: #f59e0b;
    /* Amber */
    --accent-6: #ef4444;
    /* Red */
    --accent-7: #ec4899;
    /* Pink */

    --gradient-main: linear-gradient(135deg, #6366f1, #8b5cf6, #06b6d4);
    --gradient-card: linear-gradient(145deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.04));
    --gradient-header: linear-gradient(180deg, rgba(99, 102, 241, 0.12) 0%, transparent 100%);

    --border: rgba(148, 163, 184, 0.08);
    --border-hover: rgba(99, 102, 241, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --font: 'Inter', -apple-system, system-ui, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Reset & Base
   ======================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* ========================================
   Background Particles
   ======================================== */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float 20s infinite ease-in-out;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.1);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.9);
    }

    75% {
        transform: translate(40px, 30px) scale(1.05);
    }
}

/* ========================================
   Header
   ======================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-main);
    border-radius: var(--radius-md);
    color: white;
    flex-shrink: 0;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo-text h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-stats {
    display: flex;
    gap: 10px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
}

.stat-number {
    font-weight: 700;
    color: var(--accent-1);
}

.stat-label {
    color: var(--text-muted);
    font-weight: 400;
}

/* ========================================
   Search Section
   ======================================== */
.search-section {
    position: relative;
    z-index: 10;
    padding: 32px 24px 0;
}

.search-container {
    max-width: 640px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px 6px 4px 18px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-box:focus-within {
    border-color: var(--accent-1);
    box-shadow: var(--shadow-glow);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
}

.search-icon svg {
    width: 20px;
    height: 20px;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    padding: 14px 12px;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-6);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.clear-btn.visible {
    display: flex;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

.clear-btn svg {
    width: 16px;
    height: 16px;
}

/* Filters */
.filter-row {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 7px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.filter-chip.active {
    background: var(--accent-1);
    border-color: var(--accent-1);
    color: white;
}

/* ========================================
   Results Info
   ======================================== */
.results-info {
    max-width: 1280px;
    margin: 0 auto;
    padding: 18px 24px 0;
    position: relative;
    z-index: 10;
}

#resultsText {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ========================================
   Main Content & Student Grid
   ======================================== */
.main-content {
    position: relative;
    z-index: 10;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px 40px;
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 16px;
}

/* ========================================
   Student Card
   ======================================== */
.student-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    animation: cardIn 0.4s ease both;
}

.student-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-main);
    opacity: 0;
    transition: var(--transition);
}

.student-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.student-card:hover::before {
    opacity: 1;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.card-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.card-avatar.div-a {
    background: linear-gradient(135deg, #6366f1, #818cf8);
}

.card-avatar.div-b {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-enrollment {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    margin-top: 2px;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-div {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-batch {
    background: rgba(6, 182, 212, 0.12);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-elective {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-elective2 {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-elective3 {
    background: rgba(236, 72, 153, 0.12);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-icon svg {
    width: 56px;
    height: 56px;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* ========================================
   Loading State
   ======================================== */
.loading-state {
    text-align: center;
    padding: 80px 20px;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.92) translateY(20px);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-6);
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 32px 28px;
}

.modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.modal-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    margin: 0 auto 14px;
}

.modal-avatar.div-a {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.modal-avatar.div-b {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.modal-student-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-enrollment {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.04);
}

.detail-row:last-child {
    border-bottom: none;
}

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

.detail-value {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value .badge {
    font-size: 0.78rem;
    padding: 5px 12px;
}

/* ========================================
   Scroll to Top
   ======================================== */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 90;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--accent-1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.scroll-top:hover {
    background: var(--accent-1);
    color: white;
    transform: translateY(-2px);
}

.scroll-top svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }

    .header-stats {
        align-self: stretch;
        justify-content: center;
    }

    .search-section {
        padding: 20px 16px 0;
    }

    .main-content {
        padding: 12px 16px 32px;
    }

    .student-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .results-info {
        padding: 14px 16px 0;
    }

    .modal {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .modal-body {
        padding: 24px 20px;
    }

    .logo-text h1 {
        font-size: 1.05rem;
    }

    .scroll-top {
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 400px) {
    .stat-pill {
        padding: 5px 10px;
        font-size: 0.72rem;
    }

    .filter-chip {
        padding: 6px 12px;
        font-size: 0.78rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}