@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #020617;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-glass: rgba(15, 23, 42, 0.8);
    --primary: #10b981;
    --primary-glow: rgba(16, 185, 129, 0.4);
    --accent: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --grad-linear: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Effects */
body::before {
    content: '';
    position: fixed;
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    z-index: -1;
    filter: blur(100px);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    background: var(--grad-linear);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1.2rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background: var(--bg-card);
    color: var(--primary);
    transform: translateX(5px);
}

.nav-link i {
    font-size: 1.2rem;
}

/* Main Content */
.main-viewport {
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-xl);
    transition: transform 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: rgba(16, 185, 129, 0.3);
}

/* Typography */
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1.5rem; }
h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }

/* Grid Layouts */
.grid-cols-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}
.grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}
.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--grad-linear);
    color: white;
    box-shadow: 0 10px 15px -3px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 15px 25px -5px var(--primary-glow);
    transform: scale(1.02);
}

/* Inputs */
.form-control {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Fix dropdown visibility aggressively */
select option {
    background-color: #ffffff !important;
    color: #000000 !important;
}

select.form-control option {
    background-color: #ffffff !important;
    color: #1e293b !important;
    padding: 10px;
}

select {
    color: #ffffff; /* Text color for the collapsed state */
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1.5em !important;
    padding-right: 3rem !important;
}

/* Dashboard Stats */
.stat-pill {
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    display: inline-block;
}

/* Animations */
@keyframes pulse-soft {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.fa-heartbeat {
    animation: pulse-soft 2s infinite ease-in-out;
}

.topic-link:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(8px);
    box-shadow: -5px 0 15px rgba(16, 185, 129, 0.1);
}

.sidebar-module:hover h3 {
    color: var(--primary);
}

/* Glassmorphism scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Alert utilities */
.alert {
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-success {
    background: rgba(16,185,129,0.1);
    color: var(--primary);
    border-color: rgba(16,185,129,0.2);
}
.alert-error {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border-color: rgba(239,68,68,0.2);
}
/* Fade-in animation */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Utility Classes */
.container-md { max-width: 1000px; margin: 0 auto; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-end; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-start { display: flex; justify-content: flex-start; align-items: center; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Margins & Gaps */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2.5rem; }
.mb-5 { margin-bottom: 3rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2.5rem; }
.gap-2 { gap: 2rem; }

/* Buttons */
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Panels & Typography */
.glass-panel {
    background: rgba(255,255,255,0.03);
    padding: 2rem;
    border-radius: 16px;
    border: 1px dashed rgba(255,255,255,0.1);
}
.section-title {
    font-size: 0.8rem;
    color: var(--primary);
    letter-spacing: 1px;
    font-weight: 800;
    text-transform: uppercase;
}
.textarea-lg {
    height: 300px;
    padding: 1.5rem;
    line-height: 1.6;
}

.dashboard-banner {
    height: 300px;
    background-size: cover !important;
    background-position: center !important;
    display: flex;
    align-items: center;
    padding: 4rem;
}

@media (max-width: 768px) {
    .dashboard-banner {
        height: auto;
        min-height: 250px;
        padding: 2rem;
    }
}

/* Mobile Responsive Styles */
.mobile-header {
    display: none;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.mobile-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--grad-linear);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mobile-header .logo img {
    height: 30px;
}

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 992px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        width: 280px;
        z-index: 1001;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.show {
        left: 0;
    }

    /* Mobile overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .main-viewport {
        padding: 1.5rem;
    }

    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .glass-card[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    .flex-mobile-col {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .flex-mobile-col-width-full {
        width: 100% !important;
        border-left: none !important;
        padding-left: 0 !important;
        padding-top: 2rem;
        border-top: 1px solid rgba(255,255,255,0.05);
    }

    /* Impersonation Bar Responsive */
    div[style*="impersonating"] {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 15px !important;
    }

    /* Classroom Layout Responsive */
    .classroom-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .classroom-sidebar {
        order: 2; /* Put sidebar below content on mobile */
        height: auto !important;
        margin-top: 2rem;
    }

    .lesson-content {
        padding-right: 0 !important;
        overflow: visible !important;
    }

    .scrollable {
        overflow: visible !important;
        max-height: none !important;
    }

    /* Universal Table Scroll for Mobile */
    .glass-card {
        overflow-x: auto !important;
    }
    
    table {
        min-width: 600px; /* Ensure tables don't squish too much */
    }

    /* Special case: Search bars should be full width on mobile */
    .search-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 1.5rem !important;
    }

    .modal-card {
        padding: 1.5rem !important;
        max-width: 95% !important;
    }

    .auth-wrapper .glass-card {
        padding: 2rem 1.5rem !important;
    }

    input[style*="width: 280px"], 
    select[style*="width: 280px"] {
        width: 100% !important;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
}

@media (max-width: 600px) {
    .main-viewport {
        padding: 1rem;
    }
    
    .glass-card {
        padding: 1.2rem;
        border-radius: 16px;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.3rem; }
    
    .btn {
        width: 100%;
        padding: 1rem;
    }

    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
