/**
 * ═══════════════════════════════════════════════════════════════════════════
 * ERP SYSTEM - Main Stylesheet
 * ═══════════════════════════════════════════════════════════════════════════
 * 
 * Design Philosophy:
 * - Mobile-First: Base styles for mobile, scale up with media queries
 * - CSS Grid: Primary layout system
 * - CSS Variables: For consistent theming
 * - Ultra-fast: Minimal DOM, no heavy libraries
 * 
 * @version 1.0.0
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CSS VARIABLES - Design Tokens
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* ─────────────────────────────────────────────────────────────────────
       COLOR PALETTE - Professional & Modern
       ───────────────────────────────────────────────────────────────────── */
    
    /* Primary Brand Colors */
    --color-primary: #0ea5e9;
    --color-primary-light: #38bdf8;
    --color-primary-dark: #0284c7;
    --color-primary-50: #f0f9ff;
    --color-primary-100: #e0f2fe;
    
    /* Secondary Accent */
    --color-secondary: #8b5cf6;
    --color-secondary-light: #a78bfa;
    --color-secondary-dark: #7c3aed;
    
    /* Neutral Grays */
    --color-gray-50: #f8fafc;
    --color-gray-100: #f1f5f9;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e1;
    --color-gray-400: #94a3b8;
    --color-gray-500: #64748b;
    --color-gray-600: #475569;
    --color-gray-700: #334155;
    --color-gray-800: #1e293b;
    --color-gray-900: #0f172a;
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-light: #fee2e2;
    --color-info: #3b82f6;
    --color-info-light: #dbeafe;
    
    /* ─────────────────────────────────────────────────────────────────────
       LAYOUT DIMENSIONS
       ───────────────────────────────────────────────────────────────────── */
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;
    --content-max-width: 1400px;
    
    /* ─────────────────────────────────────────────────────────────────────
       SPACING SCALE
       ───────────────────────────────────────────────────────────────────── */
    
    --space-xs: 0.25rem;   /* 4px */
    --space-sm: 0.5rem;    /* 8px */
    --space-md: 1rem;      /* 16px */
    --space-lg: 1.5rem;    /* 24px */
    --space-xl: 2rem;      /* 32px */
    --space-2xl: 3rem;     /* 48px */
    
    /* ─────────────────────────────────────────────────────────────────────
       TYPOGRAPHY
       ───────────────────────────────────────────────────────────────────── */
    
    --font-primary: 'Noto Sans Arabic', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* ─────────────────────────────────────────────────────────────────────
       BORDERS & SHADOWS
       ───────────────────────────────────────────────────────────────────── */
    
    --radius-sm: 0.25rem;  /* 4px */
    --radius-md: 0.5rem;   /* 8px */
    --radius-lg: 0.75rem;  /* 12px */
    --radius-xl: 1rem;     /* 16px */
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* ─────────────────────────────────────────────────────────────────────
       TRANSITIONS
       ───────────────────────────────────────────────────────────────────── */
    
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* ─────────────────────────────────────────────────────────────────────
       Z-INDEX LAYERS
       ───────────────────────────────────────────────────────────────────── */
    
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-sidebar: 300;
    --z-header: 400;
    --z-modal: 500;
    --z-tooltip: 600;
    --z-toast: 700;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CSS RESET & BASE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: var(--line-height-normal);
    color: var(--color-gray-800);
    background: linear-gradient(135deg, var(--color-gray-50) 0%, var(--color-gray-100) 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* RTL Support */
[dir="rtl"] {
    font-family: 'Noto Sans Arabic', 'Segoe UI', system-ui, sans-serif;
}

/* Focus States */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--color-gray-300);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-400);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN LAYOUT - CSS Grid (Mobile-First)
   ═══════════════════════════════════════════════════════════════════════════ */

.app-layout {
    display: grid;
    grid-template-areas:
        "header"
        "main";
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

/* ─────────────────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────────────────── */

.app-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: 0 var(--space-md);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
}

.header-start {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-end {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-gray-600);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--color-gray-100);
    color: var(--color-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-gray-800);
    text-decoration: none;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: var(--radius-md);
    color: white;
}

.search-box {
    display: none;
    position: relative;
}

.search-box input {
    width: 280px;
    padding: var(--space-sm) var(--space-md);
    padding-inline-start: 40px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-full);
    background: var(--color-gray-50);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

.search-box .search-icon {
    position: absolute;
    top: 50%;
    inset-inline-start: 12px;
    transform: translateY(-50%);
    color: var(--color-gray-400);
    font-size: 20px;
}

/* Header Actions */
.header-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-gray-600);
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--color-gray-100);
    color: var(--color-primary);
}

.header-btn .badge {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: var(--font-semibold);
    color: white;
    background: var(--color-danger);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--color-gray-100);
    border-radius: var(--radius-full);
}

.lang-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    color: var(--color-gray-600);
    transition: all var(--transition-fast);
}

.lang-btn.active {
    background: white;
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-avatar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-avatar:hover {
    background: var(--color-gray-100);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.user-info {
    display: none;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-gray-800);
}

.user-role {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

/* ─────────────────────────────────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────────────────────────────────── */

.app-sidebar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    z-index: var(--z-sidebar);
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-gray-900);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

[dir="rtl"] .app-sidebar {
    transform: translateX(100%);
}

.app-sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-sidebar) - 1);
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    height: var(--header-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: white;
    text-decoration: none;
}

.sidebar-logo .logo-icon {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
}

.sidebar-logo span {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
}

.sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-title {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--color-gray-400);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
}

.nav-link .material-icons {
    font-size: 22px;
    opacity: 0.8;
}

.nav-link.active .material-icons {
    opacity: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-user .avatar {
    width: 40px;
    height: 40px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─────────────────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
   ───────────────────────────────────────────────────────────────────────── */

.app-main {
    grid-area: main;
    padding: var(--space-md);
    overflow-x: hidden;
}

.content-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* Page Header */
.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.page-title-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-gray-900);
}

.page-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

.breadcrumb a {
    color: var(--color-gray-500);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--color-primary);
}

.breadcrumb-separator {
    color: var(--color-gray-300);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-gray-100);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-gray-800);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-gray-100);
    background: var(--color-gray-50);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

.btn-secondary {
    background: var(--color-gray-100);
    color: var(--color-gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-gray-200);
}

.btn-success {
    background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-danger) 0%, #dc2626 100%);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-gray-300);
    color: var(--color-gray-700);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-icon {
    padding: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--text-base);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-gray-700);
}

.form-label.required::after {
    content: ' *';
    color: var(--color-danger);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--color-gray-800);
    background: white;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

.form-control::placeholder {
    color: var(--color-gray-400);
}

.form-control.error {
    border-color: var(--color-danger);
}

.form-control.error:focus {
    box-shadow: 0 0 0 3px var(--color-danger-light);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 20px;
    padding-inline-start: 40px;
}

[dir="ltr"] select.form-control {
    background-position: right 12px center;
    padding-inline-start: 16px;
    padding-inline-end: 40px;
}

.form-error {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--color-danger);
}

.form-hint {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FILE UPLOAD
   ═══════════════════════════════════════════════════════════════════════════ */

.file-upload {
    position: relative;
}

.file-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-2xl);
    background: var(--color-gray-50);
    border: 2px dashed var(--color-gray-300);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    background: var(--color-primary-50);
    border-color: var(--color-primary);
}

.file-drop-zone .upload-icon {
    font-size: 48px;
    color: var(--color-gray-400);
}

.file-drop-zone:hover .upload-icon,
.file-drop-zone.drag-over .upload-icon {
    color: var(--color-primary);
}

.file-drop-text {
    text-align: center;
}

.file-drop-title {
    font-size: var(--text-lg);
    font-weight: var(--font-medium);
    color: var(--color-gray-700);
    margin-bottom: var(--space-xs);
}

.file-drop-subtitle {
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DOCUMENT GRID
   ═══════════════════════════════════════════════════════════════════════════ */

.documents-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

.document-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.document-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.document-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    background: var(--color-gray-100);
}

.document-preview .file-icon {
    font-size: 56px;
}

.document-preview .file-icon.pdf { color: #dc2626; }
.document-preview .file-icon.word { color: #2563eb; }
.document-preview .file-icon.excel { color: #16a34a; }
.document-preview .file-icon.image { color: #8b5cf6; }
.document-preview .file-icon.other { color: #6b7280; }

.document-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.document-category-badge {
    position: absolute;
    top: var(--space-sm);
    inset-inline-start: var(--space-sm);
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: white;
    background: var(--color-primary);
    border-radius: var(--radius-full);
}

.document-content {
    flex: 1;
    padding: var(--space-md);
}

.document-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-gray-800);
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

.document-actions {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--color-gray-100);
    background: var(--color-gray-50);
}

.document-actions .btn {
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════════════════ */

.alert {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.alert-success {
    background: var(--color-success-light);
    color: #065f46;
}

.alert-error {
    background: var(--color-danger-light);
    color: #991b1b;
}

.alert-warning {
    background: var(--color-warning-light);
    color: #92400e;
}

.alert-info {
    background: var(--color-info-light);
    color: #1e40af;
}

.alert-close {
    margin-inline-start: auto;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.alert-close:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATS CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    font-size: 28px;
}

.stat-icon.primary {
    background: var(--color-primary-100);
    color: var(--color-primary);
}

.stat-icon.success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.stat-icon.warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.stat-icon.danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-gray-900);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-base);
}

.modal-backdrop.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-gray-100);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-gray-200);
}

.modal-body {
    padding: var(--space-lg);
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-gray-100);
    background: var(--color-gray-50);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FILTER BAR
   ═══════════════════════════════════════════════════════════════════════════ */

.filter-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
}

.filter-search {
    position: relative;
    flex: 1;
}

.filter-search input {
    width: 100%;
    padding: 10px 16px;
    padding-inline-start: 44px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.filter-search .material-icons {
    position: absolute;
    top: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    color: var(--color-gray-400);
    font-size: 20px;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    background: white;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════════════════════ */

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: start;
    border-bottom: 1px solid var(--color-gray-100);
}

.table th {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-gray-500);
    background: var(--color-gray-50);
    white-space: nowrap;
}

.table td {
    font-size: var(--text-sm);
    color: var(--color-gray-700);
}

.table tbody tr:hover {
    background: var(--color-gray-50);
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.empty-state-icon {
    font-size: 80px;
    color: var(--color-gray-300);
    margin-bottom: var(--space-md);
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--color-gray-700);
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: var(--text-base);
    color: var(--color-gray-500);
    margin-bottom: var(--space-lg);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════════════════════════════ */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }

.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-muted { color: var(--color-gray-500); }

.bg-primary { background: var(--color-primary); }
.bg-success { background: var(--color-success); }
.bg-danger { background: var(--color-danger); }

.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.d-none { display: none !important; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

@media (max-width: 767px) {
    /* ─────────────────────────────────────────────────────────────────────────
       MOBILE HEADER - Optimized Layout
       ─────────────────────────────────────────────────────────────────────── */
    .app-header {
        height: var(--header-height);
        padding: 0 var(--space-sm);
        gap: var(--space-xs);
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    .header-start {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        flex: 0 0 auto;
    }

    .header-end {
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        flex: 1;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .logo {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: var(--space-xs);
        margin-inline-start: var(--space-xs);
    }

    .logo-icon {
        min-width: 32px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-md);
        background: var(--color-primary-50);
    }

    .logo-icon .material-icons {
        font-size: 18px;
        color: var(--color-primary);
    }

    .logo span {
        display: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Hide language switcher on very small screens */
    .lang-switcher {
        display: none;
    }

    .lang-btn {
        display: none;
    }

    .user-menu {
        flex: 0 0 auto;
    }

    /* Header buttons sizing for mobile */
    .header-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-btn .material-icons {
        font-size: 20px;
    }

    /* Sidebar toggle sizing */
    .sidebar-toggle {
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-toggle .material-icons {
        font-size: 20px;
    }

    /* Badge positioning for mobile */
    .header-btn .badge {
        width: 18px;
        height: 18px;
        font-size: var(--text-xs);
        top: -6px;
        right: -6px;
    }

    /* Avatar sizing for mobile */
    .user-avatar {
        width: 36px;
        height: 36px;
    }

    .user-avatar .avatar {
        width: 36px;
        height: 36px;
        font-size: var(--text-sm);
    }

    .page-title-section {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .page-title {
        font-size: var(--text-xl);
    }

    .page-actions {
        width: 100%;
        flex-direction: column;
    }

    .page-actions > * {
        width: 100%;
    }

    .card-header {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: var(--space-md);
    }

    .card-body,
    .card-footer,
    .modal-body,
    .modal-header,
    .modal-footer {
        padding: var(--space-md);
    }

    .breadcrumb,
    .filter-options {
        flex-wrap: wrap;
    }

    .filter-options {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

    .table-container {
        margin-inline: calc(var(--space-md) * -1);
        padding-inline: var(--space-md);
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 640px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLET BREAKPOINT (768px+)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
    /* Restore language switcher on tablet and above */
    .lang-switcher {
        display: flex;
    }

    .lang-btn {
        display: block;
    }

    /* Show logo text on tablet and above */
    .logo span {
        display: block;
    }

    /* Header improvements for tablet */
    .header-start {
        gap: var(--space-md);
    }

    .header-end {
        gap: var(--space-md);
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Documents Grid */
    .documents-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Filter Bar */
    .filter-bar {
        flex-direction: row;
        align-items: center;
    }
    
    /* Search Box in Header */
    .search-box {
        display: block;
    }
    
    /* User Info */
    .user-info {
        display: flex;
    }
    
    /* Page Header */
    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DESKTOP BREAKPOINT (1024px+)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
    /* Main Layout with Sidebar */
    .app-layout {
        grid-template-areas:
            "sidebar header"
            "sidebar main";
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-rows: var(--header-height) 1fr;
    }
    
    /* Sidebar always visible */
    .app-sidebar {
        position: relative;
        grid-area: sidebar;
        transform: translateX(0);
    }
    
    [dir="rtl"] .app-sidebar {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    .sidebar-close {
        display: none;
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Documents Grid */
    .documents-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Main Content Padding */
    .app-main {
        padding: var(--space-lg) var(--space-xl);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LARGE DESKTOP (1400px+)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1400px) {
    /* Documents Grid */
    .documents-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Search Box Wider */
    .search-box input {
        width: 360px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
    .app-sidebar,
    .app-header,
    .sidebar-toggle,
    .btn,
    .filter-bar {
        display: none !important;
    }
    
    .app-layout {
        display: block;
    }
    
    .app-main {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

