:root {
    /* Color Palette - Dark Mode Primary */
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --secondary: #3b82f6;
    --accent: #10b981;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    
    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Animation */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.15), transparent 25%);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* Glass Card Utilities */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--secondary));
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.btn-danger:hover { background: var(--danger-hover); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3); }

.btn-block { width: 100%; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Forms */
.input-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.view {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

.view.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* Login View */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-image: 
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.2), transparent 40%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.15), transparent 40%);
}

.login-glass {
    width: 100%;
    max-width: 400px;
    padding: 3rem 2rem;
    text-align: center;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

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

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0.5rem;
}

.logo i {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.logo h1, .logo h2 {
    font-size: 2rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.auth-toggle {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

.auth-toggle a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Main Layout */
#main-layout {
    display: flex;
}

.sidebar {
    width: 260px;
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 20;
}

.sidebar .logo {
    justify-content: flex-start;
    margin-bottom: 2.5rem;
}

.sidebar .logo h2 { font-size: 1.5rem; }

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-item i { width: 20px; height: 20px; }

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: white;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(59, 130, 246, 0.2));
    border-left: 3px solid var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    margin-top: auto;
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-info span { font-size: 0.9rem; font-weight: 600; }
.user-info .role { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-header {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(10px);
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

/* Page Views */
.page-view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page-view.active {
    display: block;
}

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

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
    border-color: rgba(99, 102, 241, 0.3);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i { width: 28px; height: 28px; }

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-top: 0.2rem;
}

/* Tables */
.widget { padding: 1.5rem; }
.widget-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-container {
    overflow-x: auto;
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.2);
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Action Bars */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    width: 300px;
}

.search-box i { color: var(--text-muted); width: 18px; }
.search-box input {
    background: transparent;
    border: none;
    padding: 10px;
    color: var(--text-main);
    width: 100%;
    outline: none;
}

.actions { display: flex; gap: 1rem; }
.hidden-input { display: none; }

/* Grid Cards */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.class-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
}

.class-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.class-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.class-header h3 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.class-header p { color: var(--text-muted); font-size: 0.9rem; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.modal {
    width: 100%;
    max-width: 450px;
    transform: scale(0.9);
    transition: var(--transition);
    display: none;
}

.modal.active {
    display: block;
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover { color: white; transform: rotate(90deg); }

.modal-body {
    padding: 1.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--glass-shadow);
    color: white;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-in { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-out { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Marks Table Inputs */
.marks-input {
    width: 70px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    font-family: var(--font-body);
    text-align: center;
    transition: var(--transition);
}

.marks-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Chrome, Safari, Edge, Opera */
.marks-input::-webkit-outer-spin-button,
.marks-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
.marks-input[type=number] {
  -moz-appearance: textfield;
}

.subject-part-row {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.subject-part-row input {
    margin-bottom: 0;
    padding: 8px 12px;
}

/* Mobile Responsiveness */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 15;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 25px rgba(0,0,0,0.5);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    .top-header {
        padding: 0 1rem;
        height: 70px;
    }
    
    .scroll-container {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-cards {
        grid-template-columns: 1fr;
    }
    
    .action-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .search-box {
        width: 100%;
    }
    
    .header-actions .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .modal {
        max-width: calc(100vw - 2rem);
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .table-container {
        border-radius: 8px;
    }
    
    .login-glass {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }
}
