/* ============================================
   COMPONENTS.CSS - Reusable UI Components
   ============================================ */

/* === Navigation Header === */
.nav-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-fixed);
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: var(--space-md) 0;
    transition: all var(--transition-base);
}

[data-theme="light"] .nav-header {
    background: rgba(255, 255, 255, 0.9);
}

.nav-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-logo {
    width: 45px;
    height: 45px;
    border-radius: var(--radius-md);
}

.nav-title {
    font-size: var(--font-size-lg);
    font-weight: 800;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition-fast);
    padding: var(--space-sm) 0;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent-cyan);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    transition: width var(--transition-base);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* === Theme Toggle Button === */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-base);
}

.theme-toggle:hover {
    border-color: var(--accent-cyan);
    transform: scale(1.05);
}

.theme-toggle .sun {
    display: none;
}

.theme-toggle .moon {
    display: block;
}

[data-theme="light"] .theme-toggle .sun {
    display: block;
}

[data-theme="light"] .theme-toggle .moon {
    display: none;
}

/* === Card Header === */
.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.card-header i {
    font-size: 1.4rem;
    color: var(--accent-cyan);
}

.card-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--text-primary);
}

/* === Page Header === */
.page-header {
    text-align: center;
    padding: 120px 0 60px;
}

.page-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-md);
}

.page-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-weight: 500;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), var(--glass-bg));
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), var(--glass-bg));
}

.toast.warning {
    border-color: rgba(245, 158, 11, 0.5);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), var(--glass-bg));
}

.toast.info {
    border-color: rgba(56, 189, 248, 0.5);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), var(--glass-bg));
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(50px);
    }
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: all var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.15);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 900;
    color: var(--accent-cyan);
    line-height: 1;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--space-xs);
}

/* === Student Card === */
.student-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: pointer;
}

.student-card:hover {
    transform: translateY(-8px);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.student-photo {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.student-info {
    padding: var(--space-lg);
}

.student-name {
    font-size: var(--font-size-lg);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.student-class {
    color: var(--accent-cyan);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.student-subject {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(56, 189, 248, 0.1);
    border-radius: var(--radius-full);
    color: var(--accent-cyan);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

/* === Loader / Spinner === */
.loader {
    width: 48px;
    height: 48px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* === Avatar === */
.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-cyan);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.avatar-lg {
    width: 150px;
    height: 150px;
}

.avatar-sm {
    width: 50px;
    height: 50px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-state-desc {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: var(--space-sm);
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: var(--space-lg);
}

.tab {
    padding: var(--space-md) var(--space-lg);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

/* === Modal === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    z-index: var(--z-modal);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: 800;
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

/* === Footer === */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--glass-border);
    padding: var(--space-3xl) 0;
    margin-top: var(--space-3xl);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-xl);
}

.footer-section h4 {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: var(--space-md);
}

.footer-section a {
    display: block;
    color: var(--text-muted);
    padding: var(--space-xs) 0;
}

.footer-section a:hover {
    color: var(--accent-cyan);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--space-xl);
    margin-top: var(--space-xl);
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
}

/* === Mobile Navigation === */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
}

.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-link {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.mobile-nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    transition: width 0.3s ease;
}

.mobile-nav-link:hover::after,
.mobile-nav-link.active::after {
    width: 100%;
}

/* === Responsive Media Queries === */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        /* Hide desktop links */
    }

    .mobile-menu-btn {
        display: block;
        /* Show hamburger */
    }

    .page-title {
        font-size: 2.5rem;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        /* 2 columns on mobile */
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .card-header h2 {
        font-size: 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stats-section .container {
        padding: 0 10px;
    }

    .stat-card {
        padding: 20px 10px;
    }

    .stat-card-number {
        font-size: 2.5rem !important;
    }

    .stat-card-icon {
        font-size: 2.5rem !important;
    }

    .actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 15px !important;
        padding: 0 20px;
    }

    .hero .btn {
        width: 100% !important;
        justify-content: center;
    }

    .page-header {
        padding: 80px 0 30px;
    }

    /* Fix overlapping/cutoff content */
    .container {
        padding: 0 16px;
        overflow-x: hidden;
        /* Prevent horizontal scroll causing 'broken' look */
    }

    .glass-card,
    .card {
        padding: 20px !important;
        border-radius: 20px;
    }

    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    /* Portfolio/Card tweaks */
    .portfolio-item,
    .project-card {
        min-width: 0;
        /* Allow flex shrinking */
    }

    /* === Mobile Bottom Navigation === */
    .mobile-bottom-nav {
        display: flex;
        /* Show flex on mobile */
    }

    /* Add padding to body to prevent content being hidden behind nav */
    body {
        padding-bottom: 80px;
    }
}

/* Base styles for bottom nav (hidden by default, shown by media query above) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(10, 10, 25, 0.9);
    /* Dark background */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    z-index: 9999;
    /* Highest priority */
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 10px);
    /* Handle iPhone notches */
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 4px;
    flex: 1;
    height: 100%;
    transition: all 0.3s ease;
}

.bottom-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.bottom-nav-item.active {
    color: var(--accent-cyan);
    /* Active color */
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px var(--accent-cyan));
}

.bottom-nav-item:active {
    transform: scale(0.95);
}