/* ============================================================
   Santos Sports ERP — Modern Design System
   ============================================================ */

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

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 68px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-accent: #3b82f6;
    --sidebar-accent-glow: rgba(59,130,246,0.15);

    /* Header */
    --header-height: 60px;
    --header-bg: #ffffff;
    --header-border: #e2e8f0;

    /* Content */
    --content-bg: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --surface-border: #e2e8f0;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Accent / Brand */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --primary-dark: #1e40af;

    /* Semantic */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-border: #059669;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-border: #d97706;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-border: #dc2626;
    --info: #06b6d4;
    --info-light: #cffafe;
    --info-border: #0891b2;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.35s ease;

    /* Z-Index */
    --z-sidebar: 100;
    --z-header: 90;
    --z-overlay: 95;
    --z-dropdown: 110;
    --z-toast: 120;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--content-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-hover); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgba(59,130,246,0.38);
    outline-offset: 2px;
}

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

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }


/* ============================================================
   LAYOUT — Sidebar + Header + Content
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    overflow: hidden;
    border-right: 1px solid var(--sidebar-border);
}

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

.sidebar__logo {
    width: 45px !important;
    height: 45px !important;
    max-width: 45px !important;
    max-height: 45px !important;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.sidebar__brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar__brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-inverse);
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-sm) 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

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

/* Menu Groups */
.menu-group { margin-bottom: var(--space-xs); }

.menu-group__title {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.5;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: opacity var(--transition-fast);
    border-radius: 0;
    box-shadow: none;
    text-align: left;
}

.menu-group__title:hover,
.menu-group__title:focus-visible {
    background: transparent;
    color: var(--sidebar-text-hover);
    opacity: 0.85;
}

.menu-group__chevron {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.menu-group.collapsed .menu-group__chevron { transform: rotate(-90deg); }
[dir="rtl"] .menu-group.collapsed .menu-group__chevron { transform: rotate(90deg); }

.menu-group__items {
    max-height: 800px;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.menu-group.collapsed .menu-group__items {
    max-height: 0;
}

/* Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 9px var(--space-md) 9px 20px;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: all var(--transition-fast);
    position: relative;
    border-radius: 0;
    text-decoration: none;
}

.menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--sidebar-accent);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transform: scaleY(0);
    transition: all var(--transition-fast);
}

[dir="rtl"] .menu-item::before {
    left: auto;
    right: 0;
    border-radius: 3px 0 0 3px;
}

.menu-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}

.menu-item:hover::before {
    opacity: 0.5;
    transform: scaleY(1);
}

.menu-item.active {
    background: var(--sidebar-accent-glow);
    color: var(--sidebar-text-hover);
}

.menu-item.active::before {
    opacity: 1;
    transform: scaleY(1);
}

.menu-item__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.menu-item.active .menu-item__icon { opacity: 1; }

.menu-item__label {
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.menu-item__badge {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--danger);
    color: #fff;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

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

/* Sidebar Footer */
.sidebar__footer {
    border-top: 1px solid var(--sidebar-border);
    padding: var(--space-md);
    flex-shrink: 0;
}

.sidebar__logout {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 9px var(--space-sm);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar__logout:hover { background: rgba(239,68,68,0.1); color: #fca5a5; }

/* Sidebar Collapsed State */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar__brand-text { opacity: 0; width: 0; }
.sidebar.collapsed .menu-group__title { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .menu-item { padding-left: 0; padding-right: 0; justify-content: center; }
[dir="rtl"] .sidebar.collapsed .menu-item { padding-left: 0; padding-right: 0; }
.sidebar.collapsed .menu-item__label { opacity: 0; width: 0; }
.sidebar.collapsed .menu-item__badge { display: none; }
.sidebar.collapsed .sidebar__logout { justify-content: center; }
.sidebar.collapsed .sidebar__logout span { display: none; }

/* ---------- Main Wrapper ---------- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-base);
}

.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed-width); }

/* ---------- Top Header ---------- */
.top-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.top-header__left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.top-header__toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.top-header__toggle:hover { background: var(--primary-light); color: var(--primary); }

.top-header__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.top-header__right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.top-header__version {
    direction: ltr;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

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

.top-header__user-name { font-weight: 600; color: var(--text-primary); font-size: 0.875rem; }
.top-header__user-role { color: var(--text-muted); font-size: 0.75rem; }

/* Language Switcher */
.language-switcher {
    display: inline-flex;
    gap: 2px;
    background: var(--content-bg);
    border-radius: var(--radius-full);
    padding: 2px;
}

.language-switcher a {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.language-switcher a:hover { background: var(--surface); color: var(--primary); }
.language-switcher span { display: none; }

/* ---------- Main Content ---------- */
.content-area {
    flex: 1;
    padding: var(--space-lg);
}

.skip-link {
    position: fixed;
    inset-inline-start: var(--space-md);
    top: var(--space-md);
    z-index: 9999;
    transform: translateY(-160%);
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    transform: translateY(0);
    color: #fff;
}


/* ============================================================
   MOBILE SIDEBAR OVERLAY
   ============================================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-overlay);
    opacity: 0;
    transition: opacity var(--transition-base);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; opacity: 1; }


/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card--clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
}

.card__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card__value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.card__footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--surface-border);
}

.card--accent { border-left: 4px solid var(--primary); }
[dir="rtl"] .card--accent { border-left: none; border-right: 4px solid var(--primary); }

/* KPI Cards (Dashboard) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-card:hover::after { opacity: 1; }

.kpi-card__value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Module Cards Grid */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    text-decoration: none;
    display: block;
    color: inherit;
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary);
    color: inherit;
}

.module-card__title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.module-card__link {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 500;
}


/* ---------- Tables ---------- */
.table-container {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table thead { background: #f8fafc; }

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.table th {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 2px solid var(--surface-border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table tfoot th, .table tfoot td {
    padding: 12px 16px;
    font-weight: 700;
    border-top: 2px solid var(--surface-border);
    background: #f8fafc;
}

.table a { font-weight: 500; }

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table td.money,
.table td.number,
.table th.money,
.table th.number,
.money,
.number,
.amount,
.currency,
.version {
    direction: ltr;
    unicode-bidi: isolate;
}


/* ---------- Forms ---------- */
.form-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.form-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-group { margin-bottom: var(--space-md); }

.form-group label,
label.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"],
input:not([type]),
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    box-sizing: border-box;
}

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

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

input[type="checkbox"], input[type="radio"] {
    width: auto;
    accent-color: var(--primary);
}

.inline-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.inline-check input { width: auto; }

/* Filter form */
.filters-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.filters-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}


/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    line-height: 1.4;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}

.btn--primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(59,130,246,0.35);
    transform: translateY(-1px);
    color: #fff;
}

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

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

.btn--success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
}

.btn--success:hover { opacity: 0.9; color: #fff; }

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

.btn--danger:hover { opacity: 0.9; color: #fff; }

.btn--ghost {
    background: transparent;
    color: var(--primary);
    padding: 8px 12px;
}

.btn--ghost:hover { background: var(--primary-light); }

.btn--sm { padding: 6px 14px; font-size: 0.8rem; }
.btn--lg { padding: 14px 28px; font-size: 1rem; }

.btn-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}


/* ---------- Alerts / Flash Messages ---------- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.alert[role="alert"],
.alert[role="status"] {
    scroll-margin-top: calc(var(--header-height) + var(--space-md));
}

.alert--success {
    background: var(--success-light);
    color: var(--success-border);
    border-left: 4px solid var(--success-border);
}

[dir="rtl"] .alert--success { border-left: none; border-right: 4px solid var(--success-border); }

.alert--warning {
    background: var(--warning-light);
    color: #92400e;
    border-left: 4px solid var(--warning-border);
}

[dir="rtl"] .alert--warning { border-left: none; border-right: 4px solid var(--warning-border); }

.alert--danger {
    background: var(--danger-light);
    color: var(--danger-border);
    border-left: 4px solid var(--danger-border);
}

[dir="rtl"] .alert--danger { border-left: none; border-right: 4px solid var(--danger-border); }

.alert--info {
    background: var(--info-light);
    color: var(--info-border);
    border-left: 4px solid var(--info-border);
}

[dir="rtl"] .alert--info { border-left: none; border-right: 4px solid var(--info-border); }


/* ---------- Panel / Section ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.empty-state {
    display: grid;
    place-items: center;
    gap: var(--space-md);
    text-align: center;
    padding: clamp(32px, 6vw, 64px) var(--space-lg);
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px dashed var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-state__icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: var(--radius-full);
    padding: 10px;
}

.empty-state__message {
    max-width: 520px;
    color: var(--text-secondary);
    font-weight: 600;
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-lg);
    background: var(--content-bg);
}

.error-card {
    width: min(560px, 100%);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: clamp(28px, 6vw, 48px);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.error-card__code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    height: 44px;
    margin-bottom: var(--space-md);
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary-dark);
    direction: ltr;
    font-weight: 800;
}

.error-card h1 {
    margin-bottom: var(--space-sm);
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.error-card__version {
    margin-top: var(--space-lg);
    color: var(--text-muted);
    direction: ltr;
    font-size: 0.82rem;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--surface-border);
    margin-top: auto;
    background: var(--surface);
}

.app-footer span {
    text-align: center;
}

.app-footer span:first-child {
    direction: ltr;
    font-weight: 700;
}

.panel__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.detail-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.detail-item {}
.detail-item__label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-item__value { font-size: 0.95rem; color: var(--text-primary); font-weight: 500; }

.scanner-video {
    width: 100%;
    max-height: 420px;
    background: #0f172a;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    object-fit: cover;
    margin-bottom: var(--space-md);
}


/* ---------- Pagination ---------- */
.pager {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
}

.pager__info {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}


/* ---------- Status Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    line-height: 1.4;
}

.badge--success { background: var(--success-light); color: var(--success-border); }
.badge--warning { background: var(--warning-light); color: #92400e; }
.badge--danger { background: var(--danger-light); color: var(--danger-border); }
.badge--info { background: var(--primary-light); color: var(--primary-dark); }
.badge--muted { background: #f1f5f9; color: var(--text-muted); }


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

.page-header h1 { margin: 0; font-size: 1.5rem; }

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


/* ---------- Spacing Utilities ---------- */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }


/* ============================================================
   LOGIN PAGE (Standalone)
   ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(59,130,246,0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(139,92,246,0.06) 0%, transparent 50%);
    animation: loginBg 15s ease-in-out infinite alternate;
}

@keyframes loginBg {
    from { transform: rotate(0deg); }
    to { transform: rotate(3deg); }
}

.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-xl);
    max-width: 420px;
    width: 100%;
    padding: 40px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}

.login-card h1 {
    text-align: center;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
}

.login-card p { text-align: center; color: var(--text-muted); margin-bottom: var(--space-lg); }

.login-card .language-switcher { justify-content: center; display: flex; margin-bottom: var(--space-lg); }


/* ============================================================
   RTL SUPPORT
   ============================================================ */

[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--sidebar-border); }
[dir="rtl"] .main-wrapper { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .sidebar.collapsed ~ .main-wrapper { margin-right: var(--sidebar-collapsed-width); margin-left: 0; }

[dir="rtl"] .menu-item { padding-left: var(--space-md); padding-right: 20px; }
[dir="rtl"] .sidebar.collapsed .menu-item { padding-left: 0; padding-right: 0; }

[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }

[dir="rtl"] input[type="number"],
[dir="rtl"] input.money,
[dir="rtl"] .money,
[dir="rtl"] .number,
[dir="rtl"] .amount,
[dir="rtl"] .currency,
[dir="rtl"] .version { direction: ltr; text-align: right; unicode-bidi: isolate; }

[dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea { text-align: right; }

[dir="rtl"] .top-header__left,
[dir="rtl"] .top-header__right,
[dir="rtl"] .btn,
[dir="rtl"] .alert,
[dir="rtl"] .inline-check {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-item {
    gap: var(--space-md);
}

[dir="rtl"] .menu-group__title {
    text-align: right;
}


/* ============================================================
   RESPONSIVE — Mobile & Tablet
   ============================================================ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: var(--shadow-xl);
    }

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

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

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .main-wrapper,
    .sidebar.collapsed ~ .main-wrapper,
    [dir="rtl"] .main-wrapper,
    [dir="rtl"] .sidebar.collapsed ~ .main-wrapper {
        margin-left: 0;
        margin-right: 0;
    }

    .content-area { padding: var(--space-md); }

    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .module-grid { grid-template-columns: 1fr; }

    .form-grid { grid-template-columns: 1fr; }
    .filters-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }
    [dir="rtl"] .page-header { align-items: flex-end; }

    .top-header__title {
        max-width: 54vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-header__version { display: none; }

    .top-header__user-role { display: none; }
}

@media (max-width: 480px) {
    .top-header { padding: 0 var(--space-md); }
    .content-area { padding: var(--space-sm); }
    .kpi-grid { grid-template-columns: 1fr 1fr; }

    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 8px 10px; }

    .btn {
        width: 100%;
        white-space: normal;
    }

    .btn-row,
    .page-header__actions {
        width: 100%;
    }

    .language-switcher a {
        padding: 5px 9px;
    }
}


/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .sidebar,
    .sidebar-overlay,
    .top-header,
    .top-header__toggle,
    .app-footer,
    .btn,
    .page-header__actions { display: none !important; }

    .main-wrapper { margin: 0 !important; }
    .content-area { padding: 0 !important; }

    .card, .panel, .table-container, .form-panel {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
