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

:root {
    --bg-dark: #0f172a;
    --bg-sidebar: #0a192f;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --sidebar-width: 280px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Glassmorphism Effect */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    position: fixed;
    left: 0;
    top: 0;
    padding: 24px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 12px;
}

.sidebar-logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition-smooth);
}

.nav-link:hover, .nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

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

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 40px;
    min-height: 100vh;
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.stat-card .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Login Page Utilities */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    outline: none;
    transition: var(--transition-smooth);
}

select.form-input {
    color: white;
    cursor: pointer;
}

select.form-input option {
    background: #0f172a; /* Match dark theme background */
    color: white;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Micro-animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 24px;
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force minimum width to ensure horizontal scroll on mobile */
}

@media (max-width: 768px) {
    .data-table {
        min-width: 800px; /* More width for complex tables like IRT */
    }
    
    .data-table th, .data-table td {
        padding: 12px;
        font-size: 0.85rem;
    }
}

.data-table th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start; /* Start from top */
    justify-content: center;
    z-index: 2000;
    overflow-y: auto; /* Allow overlay to scroll */
    padding: 40px 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 32px;
    position: relative;
    margin-bottom: 40px; /* Space at bottom */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Badges & Actions */
.badge {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-icon.delete:hover {
    color: #ef4444;
    border-color: #ef4444;
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 3000;
}

.toast {
    padding: 16px 24px;
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    animation: toastIn 0.3s ease forwards;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Custom Confirm Modal specific styles */
.confirm-modal .modal-content {
    max-width: 400px;
    text-align: center;
}

.confirm-modal .confirm-icon {
    font-size: 3rem;
    color: #f59e0b;
    margin-bottom: 16px;
}

/* Question Bank Specific */
.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.option-item input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
}

.option-item.correct {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.image-preview-container {
    width: 100%;
    height: 150px;
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview-container .placeholder {
    color: var(--text-secondary);
    text-align: center;
}
.mobile-header {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        visibility: hidden;
    }
    
    .sidebar.active {
        transform: translateX(0);
        visibility: visible;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-top: 0;
    }
    
    .mobile-header {
        display: flex !important;
        align-items: center;
        gap: 16px;
        padding: 16px 20px;
        background: var(--bg-sidebar);
        border-bottom: 1px solid var(--glass-border);
        position: sticky;
        top: 0;
        z-index: 900;
        margin: 0 -20px 24px -20px;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(4px);
        z-index: 950;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Adjust main header for mobile */
    .main-content > header {
        display: none !important; /* Hide desktop header on mobile */
    }
}

/* Global Responsive Utilities */
.responsive-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .responsive-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
    
    .glass {
        padding: 20px !important;
    }
    
    .modal-content {
        padding: 20px !important;
        max-width: 95% !important;
        margin: 20px auto !important;
    }

    .modal-overlay {
        align-items: flex-start !important;
        padding: 20px 10px !important;
        overflow-y: auto !important;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .btn-primary {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* Stack flex containers on mobile */
    .flex-stack-mobile {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
    }

    .flex-stack-mobile > div, .flex-stack-mobile > button, .flex-stack-mobile > a {
        width: 100% !important;
    }
    
    .flex-stack-mobile input {
        width: 100% !important;
    }

    /* Fix image preview for small screens */
    .image-preview-container {
        height: 120px;
    }
}

/* Ensure all glass sections stack well */
.glass {
    overflow: hidden;
}

/* Custom Table Polish */
.data-table th, .data-table td {
    white-space: nowrap;
}

.data-table td div {
    white-space: normal;
}
