@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;800&display=swap');

:root {
    --bg-dark: #090b10;
    --glass: rgba(22, 27, 34, 0.9);
    --border: rgba(255, 255, 255, 0.1);
    --accent: #38bdf8;
    --purple: #a855f7;
    --text: #f8fafc;
    --dim: #94a3b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
body { background: var(--bg-dark); color: var(--text); min-height: 100vh; overflow-x: hidden; }

.container { width: 100%; max-width: 1000px; margin: 0 auto; padding: 10px; }
.hidden { display: none !important; }
.dim { color: var(--dim); font-size: 0.8rem; }

/* COMPACT ANALYTICS */
.stat-banner {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
    background: var(--glass); border: 1px solid var(--border);
    border-radius: 16px; margin: 20px 0; padding: 10px;
}
.stat-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03); border-radius: 12px; flex: 1; min-width: 130px;
}
.stat-icon { color: var(--accent); font-size: 1.1rem; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: rgba(56, 189, 248, 0.1); border-radius: 8px; }
.stat-label { font-size: 0.6rem; text-transform: uppercase; color: var(--dim); display: block; }
.stat-value { font-size: 1.1rem; font-weight: 800; }

/* SEARCH & HERO */
.hero-section { text-align: center; padding: 20px 0; }
.brand-logo { font-size: 1.8rem; font-weight: 800; margin-bottom: 15px; }
.brand-logo span { color: var(--accent); }
.search-bar { 
    background: var(--glass); border: 1px solid var(--border); padding: 12px 20px;
    border-radius: 50px; display: flex; align-items: center; max-width: 500px; margin: 0 auto;
}
.search-bar input { background: none; border: none; color: white; width: 100%; margin: 0 10px; outline: none; }

/* ENHANCED SEARCH DROPDOWN */
.dropdown-list { 
    position: absolute; left: 10px; right: 10px; 
    background: rgba(22, 27, 34, 0.95); backdrop-filter: blur(12px);
    border-radius: 12px; z-index: 100; border: 1px solid var(--border);
    max-height: 350px; overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.dropdown-list::-webkit-scrollbar { width: 6px; }
.dropdown-list::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 3px; }
.dropdown-list::-webkit-scrollbar-track { background: transparent; }

/* ACTION BUTTON */
.action-btn {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid var(--border); color: var(--text); padding: 12px 25px;
    border-radius: 50px; cursor: pointer; margin-top: 20px; font-weight: 600;
    transition: all 0.3s; display: inline-flex; align-items: center; gap: 10px;
    font-size: 0.9rem;
}
.action-btn:hover { background: rgba(255,255,255,0.15); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.action-btn i { color: #fbbf24; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-glass { background: #161b22; border: 1px solid var(--border); width: 95%; max-width: 500px; border-radius: 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); animation: slideUp 0.3s ease; overflow: hidden; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.02); }
.modal-header h3 { margin: 0; font-size: 1.2rem; }
.close-modal { background: none; border: none; color: var(--dim); font-size: 1.2rem; cursor: pointer; transition: color 0.2s; }
.close-modal:hover { color: #fff; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.full-width { width: 100%; margin-bottom: 15px; padding: 12px; font-size: 1rem; }

/* TOPPERS SECTION */
/* .toppers-card removed, styles reused for modal content */
.glass-select { background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 8px; outline: none; cursor: pointer; }
.glass-select option { background: #161b22; }

.topper-item { display: flex; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); transition: background 0.2s; }
.topper-item:last-child { border-bottom: none; }
.topper-item:hover { background: rgba(255,255,255,0.03); }
.rank-circle { width: 28px; height: 28px; background: linear-gradient(135deg, #fbbf24, #d97706); color: #fff; font-weight: 800; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 12px; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3); }
.topper-details { flex: 1; }
.t-name { font-weight: 600; font-size: 0.95rem; }
.t-prn { font-size: 0.75rem; color: var(--dim); font-family: monospace; }
.t-sgpa { font-weight: 800; font-size: 1.1rem; color: #fbbf24; }

.result-item { 
    padding: 12px 20px; border-bottom: 1px solid var(--border); cursor: pointer; 
    transition: all 0.2s ease; border-left: 3px solid transparent;
}
.result-item:hover { background: rgba(56, 189, 248, 0.1); border-left-color: var(--accent); padding-left: 25px; }
.res-name { font-weight: 600; color: #fff; }
.res-prn { font-size: 0.75rem; color: var(--dim); font-family: monospace; margin-top: 2px; }

/* DASHBOARD */
.glass-card { background: var(--glass); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 15px; }

/* PREMIUM AI CARD UI */
.ai-metric { 
    border-left: 4px solid var(--purple); 
    background: linear-gradient(135deg, rgba(22, 27, 34, 0.95), rgba(168, 85, 247, 0.15));
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.1);
    display: flex; flex-direction: column; justify-content: center; 
    position: relative; overflow: hidden;
}
.ai-metric::after {
    content: ''; position: absolute; top: -50%; right: -50%; width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2) 0%, transparent 70%);
    pointer-events: none; filter: blur(20px);
}
.metric-value { font-size: 2.2rem; font-weight: 800; color: var(--purple); text-shadow: 0 0 20px rgba(168, 85, 247, 0.4); position: relative; z-index: 2; }
.badge-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; position: relative; z-index: 2; }
.trend-tag { font-size: 0.8rem; color: #cbd5e1; margin-top: 5px; position: relative; z-index: 2; }

.top-row { display: grid; grid-template-columns: 2fr 1fr; gap: 15px; }
.avatar { width: 55px; height: 55px; background: linear-gradient(135deg, var(--accent), var(--purple)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }

/* ACCORDION TRANSCRIPT */
.sem-block { margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--glass); overflow: hidden; }
.sem-head { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.toggle-icon { font-size: 0.7rem; color: var(--accent); transition: transform 0.3s; }
.sem-body-wrapper { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; background: rgba(0,0,0,0.2); }

/* MOBILE RESPONSIVE TABLES */
.subject-table { width: 100%; border-collapse: collapse; }
.subject-table th { display: none; }
.subject-table tr { display: block; border-bottom: 1px solid var(--border); padding: 10px 15px; }
.subject-table td { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.85rem; }
.subject-table td::before { content: attr(data-label); font-weight: 600; color: var(--dim); }
.grade-badge { background: #30363d; padding: 2px 8px; border-radius: 4px; color: var(--accent); font-weight: bold; }

@media (min-width: 768px) {
    .top-row { grid-template-columns: 2fr 1fr; }
    .subject-table th { display: table-cell; padding: 10px 15px; color: var(--dim); text-transform: uppercase; font-size: 0.7rem; text-align: left; }
    .subject-table tr { display: table-row; }
    .subject-table td { display: table-cell; padding: 12px 15px; }
    .subject-table td::before { display: none; }
    .stat-item { min-width: 140px; }
}

/* FOOTER */
.app-footer { background: #0d1117; padding: 30px 10px; text-align: center; border-top: 1px solid var(--border); }
.credits { font-size: 0.85rem; margin-top: 8px; color: var(--text); }
.credits span { color: var(--accent); font-weight: 600; }

#loader { position: fixed; inset: 0; background: var(--bg-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1000; }
.dual-ring { width: 35px; height: 35px; border: 3px solid var(--accent); border-bottom-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* --- FIX 1: Sticky Footer Logic --- */
html, body {
    height: 100%; /* Required for the wrapper to calculate height */
    margin: 0;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Takes full screen height */
}

.container {
    flex: 1 0 auto; /* This pushes the footer down by growing to fill space */
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px;
}

.app-footer {
    flex-shrink: 0; /* Prevents footer from squishing */
    background: #0d1117;
    padding: 25px 10px;
    text-align: center;
    border-top: 1px solid var(--border);
    width: 100%;
}

/* --- FIX 2: Graph Expansion Fix --- */
.chart-container {
    position: relative;
    height: 300px; /* Fixed height prevents infinite growing on scroll */
    width: 100%;
    margin-bottom: 20px;
}

/* Ensure canvas doesn't break out */
#performanceChart {
    max-height: 100% !important;
    width: 100% !important;
}
/* --- UPDATED RESPONSIVE SYSTEM --- */

:root {
    /* Fluid Font Sizes: clamp(min, preferred, max) */
    --font-h1: clamp(1.5rem, 5vw, 2.2rem);
    --font-h2: clamp(1.2rem, 4vw, 1.8rem);
    --font-body: clamp(0.85rem, 2vw, 1rem);
    --card-padding: clamp(12px, 3vw, 24px);
}

/* 1. Fix Footer Positioning */
html, body {
    height: 100%;
    margin: 0;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    flex: 1 0 auto; /* Pushes footer to bottom */
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px;
}

.app-footer {
    flex-shrink: 0;
    background: #0d1117;
    padding: 20px 10px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* 2. Fix Graph Height & Recursion */
.chart-container {
    position: relative;
    height: 250px; /* Reduced height for better look */
    width: 100%;
    margin-bottom: 20px;
}

/* 3. Smaller Squares for Mobile */
.glass-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: var(--card-padding);
    margin-bottom: 15px;
}

.top-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

.brand-logo { font-size: var(--font-h1); }
#displayName { font-size: var(--font-h2); }

/* --- MOBILE TWEAKS --- */
@media (max-width: 768px) {
    .top-row {
        grid-template-columns: 1fr; /* Stack profile and prediction */
    }
    
    .profile-info {
        padding: 15px; /* Smaller square on mobile */
    }

    .avatar {
        width: 50px; /* Scaled down avatar */
        height: 50px;
        font-size: 1.1rem;
    }

    .metric-value {
        font-size: 2rem; /* Smaller font for SGPA square */
    }

    /* Better Grid for Stats on Mobile */
    .stat-banner {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 10px;
        min-width: 0;
        width: auto;
    }
    /* Make the last item span full width for symmetry */
    .stat-item:last-child {
        grid-column: span 2;
    }

    /* Table Fix for Small Squares */
    .subject-table td {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    /* Full width buttons for easier touch */
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}