/* ============================================
   Platforma e Orareve - Kolegji AAB
   Design System
   ============================================ */

/* CSS Variables */
:root {
    --primary: #1a56db;
    --primary-dark: #1e3a8a;
    --primary-light: #dbeafe;
    --primary-50: #eff6ff;
    --secondary: #059669;
    --secondary-light: #d1fae5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --success: #059669;
    --success-light: #d1fae5;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px 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);
    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--text-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.logo-text span {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section {
    padding: 0.25rem 0;
}

.nav-section-title {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: #cbd5e1;
    font-size: 0.875rem;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-link.active {
    background: rgba(26, 86, 219, 0.15);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-version {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar-toggle:hover { background: var(--bg); color: var(--text-primary); }

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-separator { color: var(--text-muted); font-size: 0.6rem; }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.7rem; }

.btn-logout {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-logout:hover { background: var(--danger-light); color: var(--danger); }

/* Page Content */
.page-content {
    padding: 1.5rem;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-info h4 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-info p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary { background: var(--bg); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-light); color: var(--text-primary); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius);
}

.btn-icon.btn-sm { width: 30px; height: 30px; }

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 0.55rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.form-control.error { border-color: var(--danger); }
.form-control.error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.error-text {
    display: block;
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    background: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--primary-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.table-actions {
    display: flex;
    gap: 0.35rem;
}

/* Table Search */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.875rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1); }

.search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
}

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

.alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0.25rem;
    font-size: 0.9rem;
}

.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #93c5fd; }

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin { background: var(--danger-light); color: var(--danger); }
.badge-profesor { background: var(--info-light); color: var(--info); }
.badge-student { background: var(--success-light); color: var(--success); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-blue { background: var(--info-light); color: var(--info); }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 1.5rem;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }
.pagination-dots { border: none !important; color: var(--text-muted); min-width: 24px !important; padding: 0 !important; }
.pagination-info { border: none !important; font-size: 0.78rem; color: var(--text-muted); margin-left: 0.5rem; white-space: nowrap; }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.2s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p { font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

/* ============================================
   Filter Bar
   ============================================ */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 160px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.filter-group select:focus { border-color: var(--primary); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .page-content { padding: 1rem; }
    .top-bar { padding: 0 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .user-details { display: none; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-group { min-width: auto; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: auto; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--info);
    animation: toastIn 0.3s ease-out;
    max-width: 420px;
    min-width: 300px;
    font-size: 0.9rem;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast i { font-size: 1.1rem; flex-shrink: 0; }
.toast.toast-success i { color: var(--success); }
.toast.toast-error i { color: var(--danger); }
.toast.toast-warning i { color: var(--warning); }
.toast.toast-info i { color: var(--info); }

.toast-message { flex: 1; }

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0.25rem;
    transition: color 0.2s;
}
.toast-close:hover { color: var(--text-primary); }

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

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

/* ============================================
   Confirm Modal (replaces browser confirm)
   ============================================ */
.confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.confirm-modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: scaleIn 0.2s ease;
}

.confirm-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--danger-light);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.confirm-modal h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.confirm-modal p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================
   Loading Spinners & Button States
   ============================================ */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================
   User Dropdown Menu
   ============================================ */
.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background 0.2s;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: inherit;
}
.user-dropdown-trigger:hover {
    background: var(--border-light);
}

.user-dropdown-trigger .caret {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.user-dropdown.open .caret {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.9rem;
}
.user-dropdown-menu a:hover {
    background: var(--primary-50);
}
.user-dropdown-menu a i {
    color: var(--text-muted);
    width: 1rem;
    text-align: center;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.user-dropdown-menu a.danger {
    color: var(--danger);
}
.user-dropdown-menu a.danger i {
    color: var(--danger);
}

/* ============================================
   Table Sorting
   ============================================ */
.data-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}
.data-table th[data-sort]:hover {
    background: var(--primary-50);
}
.data-table th[data-sort]::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.5rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.data-table th[data-sort].asc::after {
    content: '\f0de';
    color: var(--primary);
}
.data-table th[data-sort].desc::after {
    content: '\f0dd';
    color: var(--primary);
}

/* ============================================
   Global Search (Ctrl+K)
   ============================================ */
.global-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    animation: fadeIn 0.15s ease;
}

.global-search-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    overflow: hidden;
}

.global-search-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    font-size: 1.1rem;
    outline: none;
    background: transparent;
    color: var(--text-primary);
}

.global-search-results {
    max-height: 320px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.global-search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: background 0.1s;
    color: var(--text-primary);
    text-decoration: none;
}
.global-search-item:hover, .global-search-item.active {
    background: var(--primary-50);
}
.global-search-item i {
    color: var(--text-muted);
    width: 1.25rem;
    text-align: center;
}

.global-search-hint {
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kbd {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
}

/* ============================================
   Dark Mode
   ============================================ */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #1e3a5f;
    --primary-50: #1e293b;
    --bg: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --danger-light: #3b1c1c;
    --warning-light: #3b2f1c;
    --success-light: #1c3b2f;
    --info-light: #1c2f3b;
}

[data-theme="dark"] .sidebar {
    background: #0f172a;
    border-right-color: #334155;
}

[data-theme="dark"] .top-bar {
    background: #1e293b;
    border-bottom-color: #334155;
}

[data-theme="dark"] .card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .data-table thead {
    background: #0f172a;
}

[data-theme="dark"] .data-table tbody tr {
    border-bottom-color: #334155;
}
[data-theme="dark"] .data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .form-control {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .modal-content {
    background: #1e293b;
}

[data-theme="dark"] .toast {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .confirm-modal {
    background: #1e293b;
}

[data-theme="dark"] .global-search-box {
    background: #1e293b;
}

[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: #f1f5f9;
    border-color: #475569;
}

[data-theme="dark"] .empty-state {
    color: #94a3b8;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

/* Print styles */
@media print {
    .sidebar, .top-bar, .sidebar-overlay, .page-header-actions, .btn-logout, .table-actions { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ===== Enhanced Mobile Responsiveness ===== */

/* Tablet Landscape */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    }
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* Tablet Portrait */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1000;
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .mobile-menu-btn {
        display: flex !important;
    }
    .global-search {
        display: none;
    }
    .top-bar {
        padding: 0.5rem 1rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    .stat-card {
        padding: 0.75rem !important;
    }
    .stat-number {
        font-size: 1.25rem !important;
    }
    .card {
        border-radius: 8px;
    }
    .card-header {
        padding: 0.75rem 1rem;
    }
    .card-body {
        padding: 0.75rem 1rem;
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
    }
    .page-header-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .page-header-actions .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
    .breadcrumb {
        font-size: 0.8rem;
    }
    .btn-group {
        flex-wrap: wrap;
    }
    /* Two-column chart grid becomes single column */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    .form-group {
        margin-bottom: 0.75rem;
    }
    h1 {
        font-size: 1.3rem !important;
    }
    h2 {
        font-size: 1.15rem !important;
    }
    h3 {
        font-size: 1rem !important;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .stat-card .stat-icon {
        display: none;
    }
    .top-bar .user-name {
        display: none;
    }
    .page-header {
        padding: 0;
    }
    .main-content {
        padding: 0.75rem !important;
    }
    .data-table {
        font-size: 0.8rem;
    }
    .btn {
        font-size: 0.8rem;
    }
    .modal-content,
    div[style*="max-width:500px"] {
        width: 95% !important;
        max-width: none !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn, button {
        min-height: 44px;
        min-width: 44px;
    }
    .data-table td, .data-table th {
        padding: 0.6rem 0.5rem;
    }
    .form-control, .form-select, input, select, textarea {
        min-height: 44px;
        font-size: 16px !important; /* Prevents iOS zoom */
    }
    a.nav-link, .sidebar a {
        padding: 0.75rem 1rem !important;
    }
    .schedule-item {
        min-height: 44px;
    }
}

/* Mobile menu button - hidden by default, shown on tablet/mobile */
.mobile-menu-btn {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: var(--radius);
}
.mobile-menu-btn:hover {
    background: var(--border-light);
}
