/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #818CF8;
    --secondary: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* Layout */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Login & Register Pages */
.login-page, .register-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
}

.login-container, .register-container {
    width: 100%;
    max-width: 440px;
    padding: 1rem;
}

.login-box, .register-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header, .register-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1, .register-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
}

.login-header p, .register-header p {
    color: var(--gray-500);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-col {
    flex: 1;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-600);
    cursor: pointer;
}

.forgot-link {
    color: var(--primary);
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    line-height: 1.5;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--secondary);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #D97706;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #FECACA;
}

.alert-success {
    background: #F0FDF4;
    color: #065F46;
    border-color: #BBF7D0;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-color: #FDE68A;
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-color: #BFDBFE;
}

/* Login Footer */
.login-footer, .register-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--gray-500);
}

.demo-credentials {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0 0.5rem 1.5rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1.5rem;
}

.sidebar-brand a {
    color: white;
    text-decoration: none;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    color: rgba(255,255,255,0.7);
    border-radius: var(--radius);
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.875rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-nav .icon {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.sidebar-nav .badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.sidebar-footer a {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    text-decoration: none;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 0;
}

/* Top Navbar */
.topbar {
    background: white;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-left h2 {
    font-size: 1.25rem;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Page Content */
.page-content {
    padding: 2rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.stat-card.stat-success {
    border-left-color: var(--secondary);
}

.stat-card.stat-warning {
    border-left-color: var(--warning);
}

.stat-card.stat-danger {
    border-left-color: var(--danger);
}

.stat-card.stat-info {
    border-left-color: var(--info);
}

/* Tables */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h3 {
    margin: 0;
    font-size: 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.table tr:hover {
    background: var(--gray-50);
}

.table .status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-draft {
    background: var(--gray-200);
    color: var(--gray-600);
}

.status-published {
    background: #DBEAFE;
    color: #1E40AF;
}

.status-active {
    background: #D1FAE5;
    color: #065F46;
}

.status-completed {
    background: #FEF3C7;
    color: #92400E;
}

.status-archived {
    background: #F3F4F6;
    color: #6B7280;
}

/* Exam Card */
.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.exam-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
}

.exam-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.exam-card .exam-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.exam-card .exam-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.exam-card .exam-meta span {
    display: inline-block;
    margin-right: 1rem;
}

.exam-card .exam-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-close:hover {
    color: var(--gray-700);
}

/* Exam Interface */
.exam-interface {
    max-width: 900px;
    margin: 0 auto;
}

.exam-timer {
    position: fixed;
    top: 0;
    right: 0;
    background: white;
    padding: 0.75rem 1.5rem;
    border-bottom-left-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    z-index: 200;
}

.exam-timer.warning {
    color: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.question-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.question-nav button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    background: white;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.question-nav button:hover {
    border-color: var(--primary);
}

.question-nav button.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.question-nav button.answered {
    border-color: var(--secondary);
    background: var(--secondary);
    color: white;
}

.question-nav button.review {
    border-color: var(--warning);
    background: var(--warning);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        padding: 1rem 0.5rem;
    }
    
    .sidebar-brand span,
    .sidebar-nav span:not(.icon) {
        display: none;
    }
    
    .sidebar-nav a {
        padding: 0.75rem;
        justify-content: center;
    }
    
    .sidebar-nav .icon {
        margin: 0;
        font-size: 1.25rem;
    }
    
    .sidebar-nav .badge {
        display: none;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .topbar {
        padding: 0.75rem 1rem;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .exam-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .login-box, .register-box {
        padding: 1.5rem;
    }
}

@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}