/**
 * EduMaster Pro - Design System
 * نظام التصميم الرئيسي
 * Mobile-First | RTL/LTR | Dark/Light Theme
 */

/* ============================================
   1. CSS Custom Properties (Design Tokens)
   ============================================ */

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

:root {
    /* — الألوان الأساسية — */
    --primary: #6C63FF;
    --primary-light: #8B83FF;
    --primary-dark: #5A52E0;
    --primary-glow: rgba(108, 99, 255, 0.3);
    --primary-surface: rgba(108, 99, 255, 0.08);

    --secondary: #00D9A6;
    --secondary-light: #33E4BC;
    --secondary-dark: #00B88C;

    --accent: #FF6B9D;
    --accent-light: #FF8DB5;

    /* — ألوان الحالة — */
    --success: #00E676;
    --success-bg: rgba(0, 230, 118, 0.1);
    --warning: #FFB74D;
    --warning-bg: rgba(255, 183, 77, 0.1);
    --danger: #FF5252;
    --danger-bg: rgba(255, 82, 82, 0.1);
    --info: #40C4FF;
    --info-bg: rgba(64, 196, 255, 0.1);

    /* — سيتم تجاوزها حسب الثيم — */
    --bg-primary: #0A0A14;
    --bg-secondary: #0F0F1A;
    --bg-surface: #1A1A2E;
    --bg-surface-hover: #232340;
    --bg-card: #16162A;
    --bg-input: #12121F;
    --bg-modal: rgba(0, 0, 0, 0.7);

    --text-primary: #EAEAEF;
    --text-secondary: #A0A0B8;
    --text-muted: #6B6B85;
    --text-inverse: #0A0A14;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-hover: rgba(255, 255, 255, 0.12);
    --border-color-focus: var(--primary);

    --glass: rgba(255, 255, 255, 0.03);
    --glass-hover: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* — الخطوط — */
    --font-ar: 'Cairo', 'Segoe UI', sans-serif;
    --font-en: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;

    /* — الأحجام — */
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* — المسافات — */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* — الحدود — */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* — الأبعاد — */
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --bottom-nav-height: 68px;
    --max-content-width: 1400px;

    /* — الانتقالات — */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* — Z-Index — */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-sidebar: 300;
    --z-overlay: 400;
    --z-modal: 500;
    --z-toast: 600;
    --z-tooltip: 700;
}

/* ============================================
   Light Theme
   ============================================ */
[data-theme="light"] {
    --bg-primary: #F5F5FA;
    --bg-secondary: #EBEBF2;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F0F0F5;
    --bg-card: #FFFFFF;
    --bg-input: #F5F5FA;
    --bg-modal: rgba(0, 0, 0, 0.4);

    --text-primary: #1A1A2E;
    --text-secondary: #555570;
    --text-muted: #8B8BA0;
    --text-inverse: #FFFFFF;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-hover: rgba(0, 0, 0, 0.15);

    --glass: rgba(255, 255, 255, 0.7);
    --glass-hover: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[dir="ltr"] body,
body.lang-en {
    font-family: var(--font-en);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol { list-style: none; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
    border: none;
    background: none;
}

button {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

::selection {
    background: var(--primary);
    color: white;
}

/* ============================================
   3. Layout Components
   ============================================ */

/* — App Shell — */
.app {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin var(--transition-base);
}

.main-content {
    flex: 1;
    padding: var(--space-lg);
    max-width: var(--max-content-width);
    width: 100%;
    margin: 0 auto;
}

/* — Sidebar — */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-base), width var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
}

[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.sidebar-brand {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.sidebar-section-title {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-md) var(--space-sm) var(--space-xs);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-base);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-surface);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: var(--radius-full);
}

[dir="ltr"] .nav-item.active::before {
    right: auto;
    left: 0;
}

.nav-item .icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nav-item .badge-count {
    margin-right: auto;
    margin-left: 0;
    background: var(--danger);
    color: white;
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

[dir="ltr"] .nav-item .badge-count {
    margin-left: auto;
    margin-right: 0;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--glass-hover);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--primary);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* — Header — */
.app-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    gap: var(--space-md);
    z-index: var(--z-sticky);
}

.header-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.header-menu-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.header-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-right: auto;
}

[dir="ltr"] .header-actions {
    margin-right: 0;
    margin-left: auto;
}

.header-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    font-size: 1.2rem;
}

.header-icon-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.header-icon-btn .notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

/* — Bottom Navigation (Mobile) — */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-sticky);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    padding: 0 var(--space-sm);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    min-width: 56px;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item .icon {
    font-size: 1.3rem;
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* ============================================
   4. Component Library
   ============================================ */

/* — Cards — */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* — Glass Card — */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* — Stats Cards — */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.05;
    transform: translate(30%, -30%);
    transition: opacity var(--transition-base);
}

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

.stat-card:hover::after {
    opacity: 0.1;
}

.stat-card.primary::after { background: var(--primary); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }

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

.stat-icon.primary { background: var(--primary-surface); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 1.2;
}

.stat-trend {
    font-size: var(--text-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-xs);
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* — Buttons — */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 0.1;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00C853);
    color: var(--text-inverse);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #D32F2F);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #F57C00);
    color: var(--text-inverse);
}

.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
}

.btn-ghost:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.btn-outline {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--text-md);
    border-radius: var(--radius-lg);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn-icon.sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-sm);
}

.btn-block {
    width: 100%;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* — Form Elements — */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--border-color-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-help {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

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

.form-select {
    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='%238B8BA0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
}

[dir="ltr"] .form-select {
    background-position: right 12px center;
    padding-left: 16px;
    padding-right: 32px;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    padding: var(--space-xs) 0;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.form-check-label {
    font-size: var(--text-base);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

[dir="ltr"] .toggle-slider::before {
    right: auto;
    left: 3px;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    background: white;
    transform: translateX(-21px);
}

[dir="ltr"] .toggle input:checked + .toggle-slider::before {
    transform: translateX(21px);
}

/* — Input Group — */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-input {
    border-radius: 0;
    flex: 1;
}

.input-group .form-input:first-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

[dir="ltr"] .input-group .form-input:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-input:last-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

[dir="ltr"] .input-group .form-input:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: var(--text-sm);
    white-space: nowrap;
}

/* — Tables — */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

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

.data-table thead {
    background: var(--bg-surface);
}

.data-table th {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

[dir="ltr"] .data-table th {
    text-align: left;
}

.data-table td {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: var(--glass-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* — Badges — */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-surface); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--glass-hover); color: var(--text-secondary); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* — Modal — */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

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

.modal-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

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

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* — Toast Notifications — */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    left: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

[dir="ltr"] .toast-container {
    left: auto;
    right: var(--space-lg);
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 320px;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: slideInRight var(--transition-spring) forwards;
}

[dir="ltr"] .toast {
    animation: slideInLeft var(--transition-spring) forwards;
}

.toast.removing {
    animation: slideOutRight var(--transition-base) forwards;
}

[dir="ltr"] .toast.removing {
    animation: slideOutLeft var(--transition-base) forwards;
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

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

.toast.success { border-right: 3px solid var(--success); }
.toast.error { border-right: 3px solid var(--danger); }
.toast.warning { border-right: 3px solid var(--warning); }
.toast.info { border-right: 3px solid var(--info); }

[dir="ltr"] .toast.success { border-right: none; border-left: 3px solid var(--success); }
[dir="ltr"] .toast.error { border-right: none; border-left: 3px solid var(--danger); }
[dir="ltr"] .toast.warning { border-right: none; border-left: 3px solid var(--warning); }
[dir="ltr"] .toast.info { border-right: none; border-left: 3px solid var(--info); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
}

.toast-message {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.toast-close {
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

/* — 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.3;
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: var(--text-base);
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto var(--space-lg);
}

/* — Avatar — */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--primary-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    font-size: var(--text-sm);
    flex-shrink: 0;
    overflow: hidden;
}

.avatar.sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar.lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar.xl { width: 80px; height: 80px; font-size: var(--text-2xl); }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* — Tabs — */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeIn var(--transition-base);
}

.tab-content.active {
    display: block;
}

/* — Dropdown — */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    overflow: hidden;
}

[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.dropdown-item.danger { color: var(--danger); }

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-xs) 0;
}

/* — Search Bar — */
.search-bar {
    position: relative;
    max-width: 400px;
}

.search-bar .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

[dir="ltr"] .search-bar .search-icon {
    right: auto;
    left: 14px;
}

.search-bar .form-input {
    padding-right: 40px;
}

[dir="ltr"] .search-bar .form-input {
    padding-right: 16px;
    padding-left: 40px;
}

/* — Pagination — */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-lg) 0;
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.page-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* — Progress Bar — */
.progress {
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width var(--transition-slow);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 2s infinite;
}

/* — Skeleton Loading — */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-sm);
    width: 100%;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-rect {
    height: 120px;
    width: 100%;
}

/* — Floating Action Button — */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--space-lg));
    left: var(--space-lg);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px var(--primary-glow);
    z-index: var(--z-sticky);
    transition: all var(--transition-fast);
}

[dir="ltr"] .fab {
    left: auto;
    right: var(--space-lg);
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 28px var(--primary-glow);
}

.fab:active {
    transform: scale(0.95);
}

/* — Page Header — */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 800;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* — Toolbar — */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

/* ============================================
   5. Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

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

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

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.animate-fade-in { animation: fadeIn var(--transition-base); }
.animate-fade-in-up { animation: fadeInUp var(--transition-base); }
.animate-scale-in { animation: scaleIn var(--transition-spring); }

/* Staggered animation */
.stagger > * {
    animation: fadeInUp var(--transition-base) backwards;
}
.stagger > *:nth-child(1) { animation-delay: 50ms; }
.stagger > *:nth-child(2) { animation-delay: 100ms; }
.stagger > *:nth-child(3) { animation-delay: 150ms; }
.stagger > *:nth-child(4) { animation-delay: 200ms; }
.stagger > *:nth-child(5) { animation-delay: 250ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 350ms; }
.stagger > *:nth-child(8) { animation-delay: 400ms; }

/* ============================================
   6. Utility Classes
   ============================================ */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

.fw-400 { font-weight: 400 !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-block { display: block !important; }
.d-inline-flex { display: inline-flex !important; }

.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-1 { flex: 1 !important; }
.align-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }
.gap-xs { gap: var(--space-xs) !important; }
.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }
.gap-lg { gap: var(--space-lg) !important; }

.m-0 { margin: 0 !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }
.mt-xl { margin-top: var(--space-xl) !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }

.p-0 { padding: 0 !important; }
.p-sm { padding: var(--space-sm) !important; }
.p-md { padding: var(--space-md) !important; }
.p-lg { padding: var(--space-lg) !important; }

.w-100 { width: 100% !important; }
.rounded { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }
.overflow-hidden { overflow: hidden !important; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   7. Responsive Design
   ============================================ */

/* Tablet (768px+) */
@media (min-width: 768px) {
    .main-content {
        padding: var(--space-xl);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .app-content {
        margin-right: var(--sidebar-width);
    }

    [dir="ltr"] .app-content {
        margin-right: 0;
        margin-left: var(--sidebar-width);
    }

    .header-menu-btn {
        display: none !important;
    }

    .bottom-nav {
        display: none !important;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .fab {
        bottom: var(--space-xl);
    }
}

/* Mobile Only (< 1024px) */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(100%);
    }

    [dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-sidebar) - 1);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
    }

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

    .header-menu-btn {
        display: flex;
    }

    .bottom-nav {
        display: block;
    }

    .main-content {
        padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg));
    }

    .app-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .modal {
        max-height: 85vh;
        margin: auto var(--space-md);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-width: none;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: none;
    }

    .toast {
        min-width: auto;
        max-width: calc(100vw - 2 * var(--space-lg));
    }
}

/* — Print Styles — */
@media print {
    .sidebar,
    .app-header,
    .bottom-nav,
    .fab,
    .btn,
    .toast-container,
    .modal-overlay {
        display: none !important;
    }

    .app-content {
        margin: 0 !important;
    }

    .main-content {
        padding: 0;
        max-width: none;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* ============================================
   8. Special Pages
   ============================================ */

/* — Login Page — */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 217, 166, 0.15), transparent 70%);
    bottom: -100px;
    left: -100px;
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--space-lg);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: var(--shadow-glow);
}

.login-logo img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: var(--text-2xl);
    font-weight: 800;
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--space-2xl);
}

/* — Install Wizard — */
.install-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: var(--bg-primary);
}

.install-card {
    width: 100%;
    max-width: 640px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    overflow: hidden;
}

.install-progress {
    display: flex;
    padding: var(--space-lg);
    gap: var(--space-xs);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.install-step {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.install-step.active {
    background: var(--primary-surface);
    color: var(--primary);
}

.install-step.completed {
    color: var(--success);
}

.install-step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    font-size: var(--text-xs);
    font-weight: 700;
}

.install-step.active .install-step-number {
    background: var(--primary);
    color: white;
}

.install-step.completed .install-step-number {
    background: var(--success);
    color: white;
}

/* — QR Scanner — */
.qr-scanner-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    overflow: hidden;
    aspect-ratio: 1;
    background: black;
}

.qr-scanner-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-scanner-frame {
    width: 200px;
    height: 200px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    position: relative;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.qr-scanner-frame::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--primary);
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 0; }
    50% { top: calc(100% - 2px); }
}

/* — Student Card (Print) — */
.student-card-preview {
    width: 340px;
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    margin: 0 auto;
}

.student-card-header {
    text-align: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px dashed var(--border-color);
}

.student-card-photo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-sm);
    object-fit: cover;
    border: 3px solid var(--primary);
}

.student-card-name {
    font-size: var(--text-lg);
    font-weight: 700;
}

.student-card-group {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.student-card-qr {
    text-align: center;
    padding: var(--space-md) 0;
}

.student-card-qr canvas {
    margin: 0 auto;
}

/* ============================================
   9. Notification Panel
   ============================================ */
.notif-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    z-index: var(--z-overlay);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
}

[dir="ltr"] .notif-panel {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
}

.notif-panel.open {
    transform: translateX(0);
}

.notif-panel-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notif-list {
    flex: 1;
    overflow-y: auto;
}

.notif-item {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: var(--space-md);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notif-item:hover {
    background: var(--glass-hover);
}

.notif-item.unread {
    background: var(--primary-surface);
}

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

.notif-item .notif-text {
    flex: 1;
    min-width: 0;
}

.notif-item .notif-title {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 2px;
}

.notif-item .notif-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item .notif-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   10. Grid Layouts
   ============================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}
