@charset "UTF-8";
/**
 * ============================================
 * AGM360 Design System v2.0
 * Linear-inspired Professional Design
 * Supports: Dark Mode + Light Mode
 * ============================================
 */

/* ============================================ */
/* 1. Design Tokens - Dark Mode (Default)       */
/* ============================================ */
:root {
    /* Brand Colors */
    --brand-primary: #5E6AD2;
    --brand-primary-hover: #6E7AE0;
    --brand-primary-active: #4F5ABF;
    --brand-primary-light: rgba(94, 106, 210, 0.12);
    --brand-primary-glow: rgba(94, 106, 210, 0.4);

    /* Semantic Colors */
    --color-success: #26A269;
    --color-success-light: rgba(38, 162, 105, 0.12);
    --color-warning: #E5A00D;
    --color-warning-light: rgba(229, 160, 13, 0.12);
    --color-danger: #E5484D;
    --color-danger-light: rgba(229, 72, 77, 0.12);
    --color-info: #0EA5E9;
    --color-info-light: rgba(14, 165, 233, 0.12);
    --color-purple: #8B5CF6;
    --color-purple-light: rgba(139, 92, 246, 0.12);

    /* Backgrounds */
    --bg-canvas: #08090A;
    --bg-surface: #101012;
    --bg-elevated: #16161A;
    --bg-overlay: #1C1C20;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-active: rgba(255, 255, 255, 0.06);
    --bg-selected: rgba(94, 106, 210, 0.15);

    /* Borders */
    --border-subtle: #1F1F24;
    --border-default: #2A2A30;
    --border-strong: #3A3A42;
    --border-focus: var(--brand-primary);

    /* Text */
    --text-primary: #F0F0F2;
    --text-secondary: #A8A8B3;
    --text-tertiary: #71717A;
    --text-disabled: #52525B;
    --text-inverse: #08090A;

    /* Typography */
    --font-sans: 'Inter', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --font-arabic: 'Tajawal', 'Inter', sans-serif;

    /* Font Sizes */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
    --text-md: 14px;
    --text-lg: 16px;
    --text-xl: 18px;
    --text-2xl: 22px;
    --text-3xl: 28px;
    --text-4xl: 36px;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    /* Border Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.6);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Animations */
    --ease-fast: 0.1s ease-out;
    --ease-base: 0.15s ease-out;
    --ease-slow: 0.25s ease-out;
    --ease-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Dimensions */
    --sidebar-width: 240px;
    --header-height: 48px;
    --content-max-width: 1400px;

    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-header: 300;
    --z-sidebar: 400;
    --z-modal-backdrop: 500;
    --z-modal: 600;
    --z-popover: 700;
    --z-tooltip: 800;
    --z-toast: 900;
    --z-command-palette: 1000;
}

/* ============================================ */
/* 2. Light Mode Override                       */
/* ============================================ */
[data-theme="light"] {
    --brand-primary: #5E6AD2;
    --brand-primary-hover: #4F5ABF;
    --brand-primary-active: #434EB0;
    --brand-primary-light: rgba(94, 106, 210, 0.08);
    --brand-primary-glow: rgba(94, 106, 210, 0.25);

    --bg-canvas: #FAFAFA;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-overlay: #FFFFFF;
    --bg-hover: rgba(0, 0, 0, 0.03);
    --bg-active: rgba(0, 0, 0, 0.05);
    --bg-selected: rgba(94, 106, 210, 0.08);

    --border-subtle: #F0F0F0;
    --border-default: #E5E5E8;
    --border-strong: #D4D4D8;

    --text-primary: #18181B;
    --text-secondary: #52525B;
    --text-tertiary: #71717A;
    --text-disabled: #A1A1AA;
    --text-inverse: #FAFAFA;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.15);
}

/* ============================================ */
/* 3. Reset & Base                              */
/* ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-arabic);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-canvas);
    min-height: 100vh;
    transition: background-color var(--ease-base), color var(--ease-base);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--ease-base);
}

a:hover {
    color: var(--brand-primary-hover);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

::selection {
    background: var(--brand-primary);
    color: white;
}

:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ============================================ */
/* 4. Layout - App Shell                        */
/* ============================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--ease-base), background-color var(--ease-base);
}

.app-header {
    position: fixed;
    top: 0;
    right: var(--sidebar-width);
    left: 0;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    z-index: var(--z-header);
    transition: right var(--ease-base), background-color var(--ease-base);
}

.app-main {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
    background: var(--bg-canvas);
    transition: margin var(--ease-base), background-color var(--ease-base);
}

.app-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-6);
}

.app-shell.sidebar-collapsed .app-sidebar {
    transform: translateX(100%);
}

.app-shell.sidebar-collapsed .app-header {
    right: 0;
}

.app-shell.sidebar-collapsed .app-main {
    margin-right: 0;
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(100%);
        width: 260px;
        box-shadow: var(--shadow-xl);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-header {
        right: 0;
    }

    .app-main {
        margin-right: 0;
    }
}

/* ============================================ */
/* 5. Buttons                                   */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 32px;
    padding: 0 var(--space-3);
    font-family: var(--font-arabic);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-base);
    user-select: none;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn i {
    font-size: 14px;
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    color: white;
}

.btn-primary:active {
    background: var(--brand-primary-active);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: #D13C40;
    border-color: #D13C40;
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.btn-success:hover {
    background: #1E8A56;
    border-color: #1E8A56;
    color: white;
}

.btn-sm {
    height: 26px;
    padding: 0 var(--space-2);
    font-size: var(--text-sm);
}

.btn-sm i {
    font-size: 12px;
}

.btn-lg {
    height: 40px;
    padding: 0 var(--space-5);
    font-size: var(--text-md);
}

.btn-icon {
    width: 32px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 26px;
}

.btn-block {
    width: 100%;
}

/* ============================================ */
/* 6. Cards                                     */
/* ============================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--ease-base);
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.card-title {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

.card-title i {
    color: var(--text-tertiary);
    font-size: 14px;
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    background: var(--bg-hover);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ============================================ */
/* 7. Stat Cards                                */
/* ============================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    transition: all var(--ease-base);
}

.stat-card:hover {
    border-color: var(--border-default);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: var(--brand-primary);
    opacity: 0.8;
}

.stat-card.stat-success::before { background: var(--color-success); }
.stat-card.stat-warning::before { background: var(--color-warning); }
.stat-card.stat-danger::before { background: var(--color-danger); }
.stat-card.stat-info::before { background: var(--color-info); }

.stat-card .stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.stat-card .stat-label {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.stat-card .stat-value {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-card .stat-trend {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.stat-card .stat-trend.up { color: var(--color-success); }
.stat-card .stat-trend.down { color: var(--color-danger); }

/* ============================================ */
/* 8. Badges                                    */
/* ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    line-height: 1;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    background: var(--bg-active);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.badge i {
    font-size: 10px;
}

.badge-primary {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: transparent;
}

.badge-success {
    background: var(--color-success-light);
    color: var(--color-success);
    border-color: transparent;
}

.badge-warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
    border-color: transparent;
}

.badge-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border-color: transparent;
}

.badge-info {
    background: var(--color-info-light);
    color: var(--color-info);
    border-color: transparent;
}

.badge-purple {
    background: var(--color-purple-light);
    color: var(--color-purple);
    border-color: transparent;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    display: inline-block;
}

.badge-dot.online { background: var(--color-success); box-shadow: 0 0 0 2px var(--color-success-light); }
.badge-dot.busy { background: var(--color-warning); }
.badge-dot.offline { background: var(--text-disabled); }

/* ============================================ */
/* 9. Forms                                     */
/* ============================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.form-label {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-label .required {
    color: var(--color-danger);
}

.form-hint {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.form-error {
    font-size: var(--text-sm);
    color: var(--color-danger);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3);
    font-family: var(--font-arabic);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-canvas);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: all var(--ease-base);
    outline: none;
}

.form-textarea {
    height: auto;
    min-height: 80px;
    padding: var(--space-3);
    resize: vertical;
    line-height: var(--leading-normal);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
    background: var(--bg-surface);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-disabled);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: var(--bg-hover);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-select {
    cursor: pointer;
    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='%2371717A' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left var(--space-3) center;
    padding-left: var(--space-8);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.form-check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-primary);
    cursor: pointer;
}

.form-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.form-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.form-switch .slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-default);
    border-radius: var(--radius-full);
    transition: all var(--ease-base);
}

.form-switch .slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    right: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform var(--ease-base);
    box-shadow: var(--shadow-sm);
}

.form-switch input:checked + .slider {
    background: var(--brand-primary);
}

.form-switch input:checked + .slider::before {
    transform: translateX(-16px);
}

/* ============================================ */
/* 10. Tables                                   */
/* ============================================ */
.table-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.table thead th {
    padding: var(--space-3) var(--space-4);
    text-align: right;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.table tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--ease-base);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr.clickable {
    cursor: pointer;
}

/* ============================================ */
/* 11. Avatars                                  */
/* ============================================ */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: white;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    flex-shrink: 0;
    user-select: none;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-base); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--text-lg); }

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ============================================ */
/* 12. Alerts                                   */
/* ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    border: 1px solid transparent;
    line-height: var(--leading-normal);
}

.alert i {
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: var(--color-success-light);
    color: var(--color-success);
    border-color: rgba(38, 162, 105, 0.2);
}

.alert-warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
    border-color: rgba(229, 160, 13, 0.2);
}

.alert-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border-color: rgba(229, 72, 77, 0.2);
}

.alert-info {
    background: var(--color-info-light);
    color: var(--color-info);
    border-color: rgba(14, 165, 233, 0.2);
}

/* ============================================ */
/* 13. Toast Notifications                      */
/* ============================================ */
.toast-container {
    position: fixed;
    bottom: var(--space-5);
    left: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: var(--z-toast);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 280px;
    max-width: 400px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-base);
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastSlideIn 0.3s var(--ease-spring);
}

.toast i {
    font-size: 16px;
    flex-shrink: 0;
}

.toast.toast-success i { color: var(--color-success); }
.toast.toast-error i { color: var(--color-danger); }
.toast.toast-warning i { color: var(--color-warning); }
.toast.toast-info i { color: var(--color-info); }

.toast .toast-message { flex: 1; }

.toast .toast-close {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--ease-base);
}

.toast .toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================ */
/* 14. Modals                                   */
/* ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    animation: fadeIn 0.2s var(--ease-base);
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s var(--ease-spring);
}

.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    background: var(--bg-hover);
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--ease-base);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ============================================ */
/* 15. Empty States                             */
/* ============================================ */
.empty-state {
    padding: var(--space-10) var(--space-5);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.empty-state-description {
    font-size: var(--text-base);
    color: var(--text-tertiary);
    max-width: 400px;
    margin: 0;
}

/* ============================================ */
/* 16. Loaders                                  */
/* ============================================ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-default);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 0%,
        var(--bg-active) 50%,
        var(--bg-hover) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================ */
/* 17. Command Palette                          */
/* ============================================ */
.command-palette {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: var(--z-command-palette);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    animation: fadeIn 0.2s var(--ease-base);
}

.command-palette.open {
    display: flex;
}

.command-palette-content {
    width: 90%;
    max-width: 560px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modalIn 0.25s var(--ease-spring);
}

.command-palette-input {
    width: 100%;
    padding: var(--space-4) var(--space-5);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: var(--text-lg);
    outline: none;
}

.command-palette-input::placeholder {
    color: var(--text-disabled);
}

.command-palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-2);
}

.command-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--ease-base);
}

.command-item:hover,
.command-item.selected {
    background: var(--bg-hover);
}

.command-item i {
    color: var(--text-tertiary);
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.command-item span {
    flex: 1;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.command-item kbd {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-subtle);
}

/* ============================================ */
/* 18. Theme Toggle                             */
/* ============================================ */
.theme-toggle {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-base);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: all var(--ease-base);
}

.theme-toggle .icon-sun { opacity: 1; transform: scale(1); }
.theme-toggle .icon-moon { opacity: 0; transform: scale(0.5); }

[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: scale(0.5); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: scale(1); }

/* ============================================ */
/* 19. Utilities                                */
/* ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--brand-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.hidden { display: none; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor-pointer { cursor: pointer; }

/* ============================================ */
/* 20. Animations                               */
/* ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================ */
/* 21. Print                                    */
/* ============================================ */
@media print {
    .app-sidebar,
    .app-header,
    .btn,
    .theme-toggle {
        display: none !important;
    }

    .app-main {
        margin: 0;
        padding: 0;
    }
}