/* =========================================
   1. THEME VARIABLES
   ========================================= */
:root {
    --bg-dark: #050511;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: 1px solid rgba(255, 255, 255, 0.08);
    --input-bg: rgba(0, 0, 0, 0.3);
    --text-white: #ffffff;
    --text-gray: #9ca3af;
    --accent-purple: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --blob-1: #4c1d95;
    --blob-2: #be185d;
}

/* HACKER THEME */
body.theme-hacker {
    --bg-dark: #050a05;
    --text-white: #e0e0e0;
    --text-gray: #4ade80;
    --accent-purple: #22c55e;
    --accent-glow: rgba(34, 197, 94, 0.5);
    --blob-1: #14532d;
    --blob-2: #15803d;
    font-family: 'Courier New', monospace;
}

/* OCEAN THEME */
body.theme-ocean {
    --bg-dark: #020617;
    --accent-purple: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.5);
    --blob-1: #1e3a8a;
    --blob-2: #0891b2;
}

/* MARS THEME */
body.theme-mars {
    --bg-dark: #1a0505;
    --accent-purple: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.5);
    --blob-1: #991b1b;
    --blob-2: #c2410c;
}

/* =========================================
   2. GLOBAL STYLES
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }
body.theme-hacker * { font-family: 'Courier New', monospace; letter-spacing: -0.5px; }

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 80px; /* Extra padding for mobile scroll */
    transition: background-color 0.5s ease;
}

/* Background Blobs */
.bg-blob {
    position: fixed;
    width: 600px; height: 600px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.4;
    transition: transform 0.1s ease-out;
    pointer-events: none;
}
#blob-1 { background: var(--blob-1); top: -100px; left: -100px; }
#blob-2 { background: var(--blob-2); bottom: -100px; right: -100px; }

/* =========================================
   3. NAVBAR
   ========================================= */
nav { width: 100%; padding: 25px 0; z-index: 100; position: relative; }
.nav-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.nav-controls { display: flex; gap: 12px; align-items: center; }

.logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.5rem; letter-spacing: -0.5px; }
.logo-icon { 
    width: 42px; height: 42px; 
    background: linear-gradient(135deg, var(--accent-purple), #ffffff);
    border-radius: 12px; display: flex; align-items: center; justify-content: center; 
    color: var(--bg-dark); font-size: 1.3rem; 
    box-shadow: 0 8px 20px var(--accent-glow);
}

.search-bar { 
    background: var(--input-bg); border: 1px solid rgba(255,255,255,0.1); 
    backdrop-filter: blur(10px); padding: 10px 20px; border-radius: 14px; 
    display: flex; align-items: center; gap: 10px; width: 350px; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}
.search-bar:focus-within { border-color: var(--accent-purple); box-shadow: 0 0 0 4px var(--accent-glow); width: 380px; }
.search-bar input { background: transparent; border: none; outline: none; color: var(--text-white); width: 100%; font-size: 0.95rem; }
.search-bar svg { color: var(--text-gray); width: 18px; height: 18px; }

/* Buttons */
.theme-wrapper { position: relative; }
.icon-btn { 
    background: var(--input-bg); border: 1px solid rgba(255,255,255,0.1); 
    color: var(--text-white); width: 44px; height: 44px; border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.3s; 
}
.icon-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent-purple); color: var(--accent-purple); }

.theme-menu {
    position: absolute; top: 55px; right: 0;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 10px;
    width: 160px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; gap: 5px;
    opacity: 1; visibility: visible; transform: translateY(0);
    transition: all 0.2s ease;
    z-index: 1000;
}
.theme-menu.hidden { opacity: 0; visibility: hidden; transform: translateY(-10px); pointer-events: none; }

.theme-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: 10px;
    color: var(--text-gray); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: 0.2s;
}
.theme-option:hover { background: rgba(255,255,255,0.05); color: var(--text-white); }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: block; }
.default-dot { background: #8b5cf6; box-shadow: 0 0 8px #8b5cf6; }
.hacker-dot { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.ocean-dot { background: #06b6d4; box-shadow: 0 0 8px #06b6d4; }
.mars-dot { background: #f97316; box-shadow: 0 0 8px #f97316; }

/* =========================================
   4. DASHBOARD GRID
   ========================================= */
.container { max-width: 1200px; margin: 10px auto; padding: 0 20px; position: relative; z-index: 1; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; margin-bottom: 40px; }

.hero-card, .stat-card {
    background: var(--card-bg); border: var(--card-border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 24px;
    padding: 35px; min-height: 240px; position: relative; overflow: hidden;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.02);
}

.hero-card h3 { font-size: 1.8rem; margin-bottom: 25px; font-weight: 700; letter-spacing: -0.5px; }
.hero-content { 
    background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.05); 
    padding: 20px 25px; border-radius: 18px; 
    display: flex; justify-content: space-between; align-items: center; 
}
.hero-profile { display: flex; align-items: center; gap: 15px; }
.hero-info h4 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0; }

.avatar-placeholder {
    width: 55px; height: 55px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}
.hero-avatar-large { width: 70px; height: 70px; font-size: 1.4rem; }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

.countdown-box { text-align: right; }
.countdown-number { font-size: 2.8rem; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.countdown-label { font-size: 0.7rem; color: var(--text-gray); letter-spacing: 2px; font-weight: 700; text-transform: uppercase; margin-top: 6px; }

.stat-card { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.stat-card h3 { font-size: 0.85rem; color: var(--text-gray); letter-spacing: 2px; margin-bottom: 10px; text-transform: uppercase; font-weight: 700; }
.stat-number { font-size: 5rem; font-weight: 800; color: var(--text-white); text-shadow: 0 0 20px var(--accent-glow); }

/* Birthday Mode */
.bday-title { 
    font-size: 2.2rem; font-weight: 800; 
    background: linear-gradient(to right, var(--accent-purple), #ffffff); 
    background-size: 200% auto; 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
    margin-bottom: 8px; animation: shine 3s linear infinite; 
}
@keyframes shine { to { background-position: 200% center; } }
.bday-subtitle { color: var(--accent-purple); margin-bottom: 25px; font-size: 1rem; font-weight: 500; }

.celebration-card { 
    position: relative; background: rgba(0, 0, 0, 0.3); border-radius: 20px; 
    padding: 20px; display: flex; align-items: center; gap: 20px; overflow: hidden; 
}
.celebration-card::before { 
    content: ""; position: absolute; inset: 0; padding: 2px; border-radius: 20px; 
    background: linear-gradient(45deg, var(--accent-purple), #ffffff, var(--accent-purple)); 
    background-size: 400% 400%; 
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); 
    -webkit-mask-composite: xor; mask-composite: exclude; 
    animation: border-rotate 4s linear infinite; 
}
@keyframes border-rotate { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
.celebrating-text { color: var(--accent-purple); font-weight: 600; letter-spacing: 0.5px; }
.animate-slide-in { animation: slideIn 0.5s ease-out forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   5. STUDENT LIST
   ========================================= */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.list-header h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.5px; }
.filters { background: rgba(255,255,255,0.05); padding: 5px; border-radius: 12px; display: flex; gap: 4px; }
.filter-btn { background: transparent; border: none; padding: 8px 16px; border-radius: 8px; color: var(--text-gray); cursor: pointer; transition: 0.3s; font-weight: 600; font-size: 0.9rem; }
.filter-btn.active { background: rgba(255,255,255,0.1); color: var(--text-white); shadow: 0 4px 10px rgba(0,0,0,0.1); }
.filter-btn:hover { color: var(--text-white); }

.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-bottom: 40px; }

/* Cards */
.student-card {
    background-color: transparent; perspective: 1000px;
    height: 130px; cursor: pointer; opacity: 0; animation: fadeInUp 0.6s ease forwards;
}
.card-inner {
    position: relative; width: 100%; height: 100%; text-align: center;
    transition: transform 0.8s; transform-style: preserve-3d;
    border-radius: 18px; background: var(--card-bg); border: var(--card-border);
}
.student-card.flipped .card-inner { transform: rotateY(180deg); }
.card-front, .card-back {
    position: absolute; width: 100%; height: 100%;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    border-radius: 18px; padding: 20px; display: flex; align-items: center;
}
.card-front { gap: 15px; z-index: 2; }
.card-back {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    transform: rotateY(180deg); flex-direction: column; justify-content: center;
    color: var(--text-white); padding: 15px; border: 1px solid var(--accent-purple);
}

.student-card::after {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 18px; z-index: 1; pointer-events: none;
    background: radial-gradient(600px circle at var(--mouse-x) var(--mouse-y), rgba(255, 255, 255, 0.06), transparent 40%);
    opacity: 0; transition: opacity 0.5s;
}
.student-card:hover::after { opacity: 1; }

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

.student-info { display: flex; flex-direction: column; gap: 3px; text-align: left; z-index: 3; }
.student-info h4 { font-size: 1.05rem; font-weight: 700; margin-bottom: 2px; }
.meta-tags { display: flex; gap: 5px; margin-bottom: 2px; flex-wrap: wrap; }
.hero-tags { margin-top: 5px; }
.zodiac-tag, .age-tag { 
    font-size: 0.65rem; padding: 2px 6px; border-radius: 8px; 
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; 
}
.zodiac-tag { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.3); }
.age-tag { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.roll-info { font-size: 0.75rem; color: var(--text-gray); font-weight: 500; }
.date-badge { margin-left: auto; text-align: right; z-index: 3; }
.date-badge div { font-size: 0.9rem; font-weight: 600; }
.days-left { font-size: 0.7rem; color: var(--text-gray); margin-top: 3px; font-weight: 600; letter-spacing: 0.5px; }
.trivia-text { font-size: 0.8rem; line-height: 1.4; text-align: center; font-weight: 500; }
.trivia-title { font-size: 0.7rem; color: var(--accent-purple); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; font-weight: 700; }

.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 40px; }
.page-btn { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-gray); padding: 10px 20px; border-radius: 10px; cursor: pointer; transition: 0.3s; font-weight: 600; font-size: 0.9rem; }
.page-btn:hover:not(.disabled) { background: var(--accent-purple); color: var(--bg-dark); border-color: var(--accent-purple); box-shadow: 0 0 20px var(--accent-glow); }
.page-btn.disabled { opacity: 0.4; cursor: not-allowed; }

footer { text-align: center; color: var(--text-gray); font-size: 0.8rem; padding-bottom: 30px; opacity: 0.6; }

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px);
    z-index: 2000; display: flex; justify-content: center; align-items: center;
    opacity: 1; visibility: visible; transition: all 0.3s ease;
}
.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-content {
    background: var(--bg-dark); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px; padding: 25px; width: 90%; max-width: 600px;
    box-shadow: 0 0 30px var(--accent-glow);
    transform: scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--accent-purple);
}
.modal.hidden .modal-content { transform: scale(0.9); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-white); }
.close-btn { background: transparent; border: none; color: var(--text-gray); font-size: 1.8rem; cursor: pointer; line-height: 1; }
.stats-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.stat-box { background: rgba(255, 255, 255, 0.05); padding: 15px; border-radius: 14px; text-align: center; border: 1px solid rgba(255, 255, 255, 0.05); }
.stat-label { display: block; font-size: 0.75rem; color: var(--text-gray); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1px; }
.stat-val { font-size: 1.2rem; color: var(--accent-purple); font-weight: 700; }
.chart-container { position: relative; height: 250px; width: 100%; }

/* =========================================
   8. SMARTPHONE MEDIA QUERY (PERFECTED)
   ========================================= */
@media (max-width: 480px) {
    .container { padding: 0 15px; margin-top: 10px; }
    
    /* Navbar: Logo Left, Buttons Right, Search Below */
    .nav-container { flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 10px 15px; }
    .logo { flex-grow: 1; font-size: 1.2rem; }
    .nav-controls { display: flex; gap: 8px; }
    .search-bar { order: 3; width: 100%; margin-top: 5px; padding: 10px 15px; font-size: 0.9rem; }
    .icon-btn { width: 38px; height: 38px; border-radius: 10px; }

    /* --- FIX: Theme Menu Positioning on Mobile --- */
    .theme-wrapper { position: relative; }
    .theme-menu {
        top: 45px; /* Adjusted for smaller buttons */
        right: 0px; /* Aligns with the right edge of the container */
        width: 150px;
        max-width: calc(100vw - 40px); /* Ensures it never overflows screen width */
    }
    /* --------------------------------------------- */

    /* Layout */
    .dashboard-grid { grid-template-columns: 1fr; gap: 15px; margin-bottom: 25px; }
    
    /* Hero & Stat Cards */
    .hero-card, .stat-card { padding: 20px; min-height: auto; border-radius: 20px; }
    .hero-card h3 { font-size: 1.4rem; margin-bottom: 15px; text-align: center; }
    .hero-content { flex-direction: column; padding: 15px; gap: 12px; }
    .hero-profile { flex-direction: column; gap: 10px; }
    .hero-avatar-large { width: 60px; height: 60px; font-size: 1.2rem; }
    .countdown-number { font-size: 2.5rem; }
    .stat-number { font-size: 4rem; }
    .bday-title { font-size: 1.8rem; text-align: center; }
    .celebration-card { flex-direction: column; text-align: center; padding: 15px; gap: 10px; }

    /* List & Grid */
    .list-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 15px; }
    .filters { width: 100%; padding-bottom: 5px; scrollbar-width: none; }
    .filters::-webkit-scrollbar { display: none; }
    .student-grid { grid-template-columns: 1fr; gap: 12px; }
    .student-card { height: auto; min-height: 100px; }
    .card-front, .card-back { padding: 15px; }
    
    /* Small Elements */
    .avatar-placeholder { width: 45px; height: 45px; font-size: 0.9rem; min-width: 45px; }
    .student-info h4 { font-size: 1rem; }
    .zodiac-tag, .age-tag { font-size: 0.6rem; padding: 1px 5px; }
    .date-badge div { font-size: 0.8rem; }

    /* Modal */
    .modal-content { padding: 20px; width: 95%; max-height: 85vh; overflow-y: auto; }
    .stats-overview { grid-template-columns: 1fr; gap: 10px; }
    .chart-container { height: 220px; }
}