/* ═══════════════════════════════════════════════════════
   NEXUS ERP — Premium Design System v2.0
   Premium • Refined • World-Class
   RTL Support: Arabic & Kurdish
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables ─────────────────────────────────── */
:root {
  /* ── Dark (default) — refined slate-navy, not pure black ── */
  --bg-primary: #0c111b;
  --bg-secondary: #1e2839;
  /* The pharmacy launcher's card edge (pharmacy.html reads the --card-gold-edge names). It was
     gold; it is now the calm edge every other card has, turning accent blue on hover. */
  --card-edge: rgba(255,255,255,.10);
  --card-edge-hover: rgba(96,165,250,.55);
  --card-gold-edge: var(--card-edge);
  --card-gold-edge-hover: var(--card-edge-hover);
  --border-input: rgba(255,255,255,0.14);
  --bg-tertiary: #2a3650;
  --bg-card: #141b2b;
  --bg-card-hover: #1c2538;
  --bg-input: #0f1521;
  --bg-sidebar: #0a0f18;

  --border-primary: rgba(255,255,255,0.08);
  --border-secondary: rgba(255,255,255,0.11);
  --border-focus: #3b82f6;

  --text-primary: #e7edf5;
  --text-secondary: #97a3b8;
  --text-tertiary: #828ea2;
  --text-inverse: #0c111b;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-subtle: rgba(59,130,246,0.14);
  --accent-glow: rgba(59,130,246,0.22);
  --primary: #3b82f6;

  --success: #34d399;
  --success-bg: rgba(52,211,153,0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251,191,36,0.12);
  --danger: #f87171;
  --danger-bg: rgba(248,113,113,0.12);
  --info: #60a5fa;
  --info-bg: rgba(96,165,250,0.12);

  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;
  --header-h: 60px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 0 1px rgba(255,255,255,0.02) inset;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 200ms;
}

/* Premium Lucide icon system (matches the Feather icons.js set) */
svg.lucide { width: 1em; height: 1em; stroke-width: 2; vertical-align: -0.125em; flex-shrink: 0; }

/* Light Theme */
[data-theme="light"] {
  /* A touch deeper than the cards, so a white card reads as sitting ON the page instead of
     dissolving into it. The complaint was that everything was white on white and hard to look at
     for a whole shift; the fix is separation, not darkness. A cool slate, not lavender-grey. */
  --bg-primary: #eef2f7;
  --bg-secondary: #ffffff;
  --card-edge: #dbe2eb;
  --card-edge-hover: rgba(37,99,235,.50);
  --card-gold-edge: var(--card-edge);
  --card-gold-edge-hover: var(--card-edge-hover);
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  /* A field is a faint cool fill with a real edge: it reads as a box to type in, where the old
     solid grey fill read as a disabled one. */
  --bg-input: #f8fafc;
  --bg-sidebar: #ffffff;
  /* Borders were 5% and 8% black — close enough to invisible that cards, inputs and table rows
     had no edge at all, which is most of why the screen felt flat and tiring. Slate-tinted rather
     than pure black so they read as a line and not as grime. */
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  --border-input: #d3dbe6;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-inverse: #ffffff;
  /* navy accent; each meaning a clear colour that still reads at 4.5:1 on white — the old
     green and amber were so dark they looked like mud */
  --accent: #1D4ED8; --accent-hover: #1E40AF; --accent-subtle: rgba(37,99,235,0.09); --accent-glow: rgba(37,99,235,0.16); --primary: #1D4ED8; --border-focus: #2563EB;
  --success: #047857; --success-bg: rgba(16,185,129,0.12); --warning: #B45309; --warning-bg: rgba(245,158,11,0.14); --danger: #DC2626; --danger-bg: rgba(239,68,68,0.10); --info: #2563EB; --info-bg: rgba(59,130,246,0.10);
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-md: 0 4px 12px rgba(16,24,40,0.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.12);
  --shadow-card: 0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.04);
}

[data-theme="light"] input[type="date"].form-input,
[data-theme="light"] input[type="datetime-local"].form-input { color-scheme: light; }

/* Midnight Blue (Deep Sea) Theme */
[data-theme="midnight"] {
  --bg-primary: #0a1424;
  --bg-secondary: #1a2c49;
  --bg-tertiary: #16263f;
  --bg-card: #102441;
  --bg-card-hover: #142b4d;
  --bg-input: #0d1b30;
  --bg-sidebar: #081120;
  --border-primary: rgba(125,165,225,0.10);
  --border-secondary: rgba(125,165,225,0.16);
  --text-primary: #e9eff8;
  --text-secondary: #9fb2d0;
  --text-tertiary: #647894;
  --text-inverse: #04122a;
  --accent: #4f8df5;
  --accent-hover: #6ba3ff;
  --accent-subtle: rgba(79,141,245,0.15);
  --accent-glow: rgba(79,141,245,0.28);
  --primary: #4f8df5;
  --border-focus: #4f8df5;
  --shadow-card: 0 4px 12px -1px rgba(0,0,0,0.4), 0 0 1px rgba(255,255,255,0.03) inset;
}

/* Nord (Arctic Cool) Theme */
[data-theme="nord"] {
  --bg-primary: #2e3440;
  --bg-secondary: #3b4252;
  --bg-tertiary: #434c5e;
  --bg-card: #3b4252;
  --bg-card-hover: #434c5e;
  --bg-input: #4c566a;
  --bg-sidebar: #2e3440;
  --border-primary: rgba(216,222,233,0.1);
  --border-secondary: rgba(216,222,233,0.15);
  --text-primary: #eceff4;
  --text-secondary: #c0c8d6;
  --text-tertiary: #8a93a5;
  --text-inverse: #2e3440;
  --accent: #88c0d0;
  --accent-hover: #8fbcbb;
  --accent-subtle: rgba(136,192,208,0.15);
  --accent-glow: rgba(136,192,208,0.3);
  --primary: #5e81ac;
  --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.3), 0 0 1px rgba(255,255,255,0.05) inset;
}

/* Forest (Clinical Mint) Theme */
[data-theme="forest"] {
  --bg-primary: #051610;
  --bg-secondary: #123420;
  --bg-tertiary: #133428;
  --bg-card: #0b221a;
  --bg-card-hover: #0e2b21;
  --bg-input: #133428;
  --bg-sidebar: #081a14;
  --border-primary: rgba(16,185,129,0.15);
  --border-secondary: rgba(16,185,129,0.25);
  --text-primary: #eaf6f0;
  --text-secondary: #9bc4b3;
  --text-tertiary: #6b8a7e;
  --text-inverse: #022c22;
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-subtle: rgba(16,185,129,0.15);
  --accent-glow: rgba(16,185,129,0.3);
  --primary: #059669;
  --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.3), 0 0 1px rgba(16,185,129,0.1) inset;
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

[dir="rtl"] body { font-family: 'Vazirmatn', 'Noto Sans Arabic', 'Inter', sans-serif; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ─── App Layout ────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100vh;
  transition: grid-template-columns var(--duration) var(--ease);
}

.app-layout.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 100;
  transition: all var(--duration) var(--ease);
}

[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border-primary); }

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1D4ED8 0%, #13315C 50%, #13315C 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(29,78,216,0.3);
}

.sidebar-brand-text { overflow: hidden; white-space: nowrap; transition: opacity var(--duration) var(--ease), width var(--duration) var(--ease); }
.sidebar-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.sidebar-brand-tier { font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.sidebar-collapsed .sidebar-brand-text { opacity: 0; width: 0; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 6px; }
.sidebar-section { margin-bottom: 4px; }

.sidebar-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-tertiary);
  padding: 10px 14px 4px; white-space: nowrap; overflow: hidden;
}

.sidebar-collapsed .sidebar-section-title { font-size: 0; padding: 8px 0 4px; text-align: center; }
.sidebar-collapsed .sidebar-section-title::after { content: '···'; font-size: 10px; color: var(--text-tertiary); }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 150ms var(--ease);
  white-space: nowrap; position: relative; user-select: none; margin-bottom: 1px;
}

.sidebar-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sidebar-item.active {
  background: linear-gradient(135deg, rgba(29,78,216,0.12) 0%, rgba(19,49,92,0.08) 100%);
  color: var(--accent); font-weight: 600;
}

.sidebar-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: linear-gradient(180deg, var(--accent), #13315C);
  border-radius: 0 3px 3px 0;
}

[dir="rtl"] .sidebar-item.active::before { left: auto; right: 0; border-radius: 3px 0 0 3px; }

.sidebar-item-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.sidebar-item.active .sidebar-item-icon { opacity: 1; }
.sidebar-item-label { overflow: hidden; transition: opacity var(--duration) var(--ease); }
.sidebar-collapsed .sidebar-item-label { opacity: 0; width: 0; }
.sidebar-collapsed .sidebar-item { justify-content: center; padding: 10px; }

/* Locked modules */
.sidebar-item.locked { opacity: 0.3; cursor: not-allowed; filter: grayscale(0.5); }
.sidebar-item.locked:hover { opacity: 0.5; background: rgba(29,78,216,0.04); }
.sidebar-item.locked::after { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2313315C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='11' x='3' y='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E"); margin-left: auto; opacity: 0.7; line-height: 0; }
[dir="rtl"] .sidebar-item.locked::after { margin-left: 0; margin-right: auto; }
.sidebar-collapsed .sidebar-item.locked::after { display: none; }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border-primary); flex-shrink: 0; }
.sidebar-toggle { width: 100%; padding: 7px; border-radius: var(--radius-sm); background: var(--bg-tertiary); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: all 150ms var(--ease); font-size: 12px; }
.sidebar-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ─── Header ────────────────────────────────────────── */
.header {
  grid-area: header; height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 16px; z-index: 90;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.header-search { position: relative; width: 280px; }
.header-search input {
  width: 100%; padding: 7px 12px 7px 34px;
  background: var(--bg-input); border: 1px solid var(--border-primary);
  border-radius: var(--radius-full); color: var(--text-primary);
  font-size: 12.5px; outline: none; transition: all 150ms var(--ease);
}
[dir="rtl"] .header-search input { padding: 7px 34px 7px 12px; }
.header-search input::placeholder { color: var(--text-tertiary); }
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.header-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-tertiary); }
[dir="rtl"] .header-search-icon { left: auto; right: 10px; }

.header-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms var(--ease); position: relative;
}
.header-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.header-btn .badge { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; background: var(--danger); border-radius: 50%; border: 2px solid var(--bg-secondary); }

.header-user { display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: var(--radius-full); cursor: pointer; transition: all 150ms var(--ease); }
.header-user:hover { background: var(--bg-tertiary); }
.header-user-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #1D4ED8 0%, #13315C 100%); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: white; }
.header-user-info { display: flex; flex-direction: column; }
.header-user-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.header-user-role { font-size: 10px; color: var(--text-tertiary); line-height: 1.2; }

.lang-switcher { display: flex; gap: 1px; background: var(--bg-input); border-radius: var(--radius-full); padding: 2px; }
.lang-btn { padding: 3px 8px; border-radius: var(--radius-full); background: transparent; color: var(--text-tertiary); font-size: 10px; font-weight: 600; transition: all 150ms var(--ease); }
.lang-btn.active { background: var(--accent); color: white; }

/* ─── Main Content ──────────────────────────────────── */
.main-content { grid-area: main; overflow-y: auto; padding: 20px 24px; background: var(--bg-primary); }

/* ─── Page Header ───────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; }

/* ─── Stat Cards ────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-primary);
  border-radius: var(--radius-md); padding: 18px 20px;
  transition: all 300ms var(--ease); position: relative; overflow: hidden;
  box-shadow: var(--shadow-card);
}

.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, #13315C 50%, #13315C 100%);
  opacity: 0; transition: opacity 300ms var(--ease);
}

.stat-card::after {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 100px; height: 100px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  opacity: 0; transition: opacity 400ms var(--ease); pointer-events: none;
}

.stat-card:hover { border-color: var(--border-secondary); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card:hover::before { opacity: 1; }
.stat-card:hover::after { opacity: 0.5; }

.stat-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.stat-card-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-card-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-card-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-card-icon.purple { background: var(--accent-subtle); color: var(--accent); }
.stat-card-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-card-trend { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.stat-card-trend.up { color: var(--success); }
.stat-card-trend.down { color: var(--danger); }

.stat-card-value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-card-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

/* ─── Data Tables ───────────────────────────────────── */
.data-table-wrap { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); }
.data-table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-primary); gap: 12px; }
.data-table-toolbar-left { display: flex; align-items: center; gap: 8px; }
.data-table-toolbar-right { display: flex; align-items: center; gap: 8px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--bg-tertiary); }
.data-table th { padding: 10px 16px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table td { padding: 10px 16px; font-size: 12.5px; border-top: 1px solid var(--border-primary); vertical-align: middle; text-align: left; overflow: hidden; text-overflow: ellipsis; }
[dir="rtl"] .data-table th,
[dir="rtl"] .data-table td { text-align: right; }
.data-table tbody tr { transition: all 120ms var(--ease); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.01); }
.data-table tbody tr:nth-child(even):hover { background: var(--bg-card-hover); }
.data-table-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-top: 1px solid var(--border-primary); font-size: 12px; color: var(--text-secondary); }

/* ─── Buttons ───────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; transition: all 180ms var(--ease); white-space: nowrap; position: relative; overflow: hidden; }
.btn-primary { background: linear-gradient(135deg, #1D4ED8 0%, #13315C 100%); color: white; border: none; }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(29,78,216,0.35); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-secondary); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-tertiary); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-lg { padding: 10px 22px; font-size: 14px; border-radius: var(--radius-md); }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ─── Badges ────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-full); font-size: 10.5px; font-weight: 600; white-space: nowrap; letter-spacing: 0.02em; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ─── Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-input { width: 100%; padding: 9px 12px; background: var(--bg-input); border: 1px solid var(--border-input, var(--border-primary)); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; outline: none; transition: all 150ms var(--ease); }
.form-input:focus { border-color: var(--accent); background: var(--bg-secondary); box-shadow: 0 0 0 3px var(--accent-subtle); }
.form-input::placeholder { color: var(--text-tertiary); }

/* ─── Cards ─────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-card); }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ─── Login Page ────────────────────────────────────── */
.login-page { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); position: relative; overflow: hidden; }

.login-page::before {
  content: ''; position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(29,78,216,0.15) 0%, transparent 70%);
  top: -200px; right: -200px; pointer-events: none;
  
}

.login-page::after {
  content: ''; position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(19,49,92,0.1) 0%, transparent 70%);
  bottom: -100px; left: -100px; pointer-events: none;
  
}

@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -15px) scale(1.05); }
  66% { transform: translate(-10px, 10px) scale(0.95); }
}

.login-card {
  width: 380px; max-width: 90vw;
  background: var(--bg-card); border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl); padding: 36px;
  position: relative; z-index: 1;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(20px);
}

.login-logo { width: 52px; height: 52px; background: linear-gradient(135deg, #1D4ED8 0%, #13315C 50%, #13315C 100%); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: white; margin: 0 auto 18px; box-shadow: 0 6px 20px rgba(29,78,216,0.3); }
.login-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em; }
.login-subtitle { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 28px; }

.login-btn { width: 100%; padding: 10px; background: linear-gradient(135deg, #1D4ED8 0%, #13315C 50%, #13315C 100%); color: white; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 250ms var(--ease); margin-top: 8px; }
.login-btn:hover { box-shadow: 0 6px 24px rgba(29,78,216,0.35); transform: translateY(-2px); }
.login-btn:active { transform: translateY(0); }

.login-error { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px; display: none; border-left: 3px solid var(--danger); }
[dir="rtl"] .login-error { border-left: none; border-right: 3px solid var(--danger); }
.login-error.show { display: block; animation: fadeIn 200ms var(--ease); }
.login-lang { display: flex; justify-content: center; margin-top: 18px; }

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; visibility: hidden; transition: all 250ms var(--ease); }
.modal-overlay.show, .modal-overlay.active { opacity: 1; visibility: visible; }

.modal { background: var(--bg-card); border: 1px solid var(--border-secondary); border-radius: var(--radius-xl); padding: 28px; width: 420px; max-width: 92vw; box-shadow: var(--shadow-lg); transform: scale(0.92) translateY(10px); transition: transform 300ms var(--ease-bounce); }
.modal-overlay.show .modal, .modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-icon { width: 52px; height: 52px; background: var(--accent-subtle); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 22px; }
.modal-title { text-align: center; font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-desc { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 14px; border-top: 1px solid var(--border-primary); margin-top: 14px; }
.modal-body { max-height: 60vh; overflow-y: auto; padding: 2px 0; }

/* Select styling */
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
[dir="rtl"] select.form-input { background-position: left 12px center; padding-right: 14px; padding-left: 32px; }
textarea.form-input { resize: vertical; min-height: 72px; }

/* ─── Form Tabs ────────────────────────────────────── */
.form-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-primary); margin-bottom: 18px; overflow-x: auto; }
.form-tab { padding: 9px 16px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; transition: all 150ms var(--ease); white-space: nowrap; }
.form-tab:hover { color: var(--text-primary); }
.form-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.form-tab-panel { display: none; }
.form-tab-panel.active { display: block; animation: fadeIn 200ms var(--ease); }

/* ─── Form Row ─────────────────────────────────────── */
.form-row { display: grid; gap: 10px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 600px) { .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; } }

/* ─── Toggle Switch ────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; }
.toggle-label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.toggle-sublabel { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-tertiary); border-radius: 11px; cursor: pointer; transition: background 200ms; border: 1px solid var(--border-secondary); }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: transform 200ms var(--ease-bounce); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ─── Upload ───────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border-secondary); border-radius: var(--radius-lg); padding: 28px; text-align: center; cursor: pointer; transition: all 200ms var(--ease); background: var(--bg-tertiary); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-subtle); }
.upload-zone-icon { font-size: 28px; margin-bottom: 6px; opacity: 0.5; }
.upload-zone-text { font-size: 12px; color: var(--text-secondary); }
.upload-zone-text strong { color: var(--accent); }
.upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 10px; }
.upload-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-primary); }
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb-remove { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; background: rgba(239,68,68,.9); color: white; border: none; border-radius: 50%; cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center; }
[dir="rtl"] .upload-thumb-remove { right: auto; left: 3px; }
.upload-thumb-main { position: absolute; bottom: 3px; left: 3px; font-size: 8px; background: var(--accent); color: white; padding: 2px 5px; border-radius: 3px; font-weight: 600; }
.upload-progress { height: 2px; background: var(--bg-tertiary); border-radius: 1px; margin-top: 6px; overflow: hidden; }
.upload-progress-bar { height: 100%; background: var(--accent); border-radius: 1px; transition: width 200ms; }

/* ─── Tags ─────────────────────────────────────────── */
.tags-input-wrap { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px 10px; background: var(--bg-tertiary); border: 1px solid var(--border-primary); border-radius: var(--radius-md); min-height: 40px; cursor: text; transition: border-color 200ms; }
.tags-input-wrap:focus-within { border-color: var(--accent); }
.tag-chip { display: inline-flex; align-items: center; gap: 3px; background: var(--accent-subtle); color: var(--accent); padding: 2px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 500; }
.tag-chip-remove { cursor: pointer; opacity: 0.7; font-size: 13px; line-height: 1; }
.tag-chip-remove:hover { opacity: 1; }
.tags-input { border: none; background: transparent; color: var(--text-primary); font-size: 12.5px; outline: none; flex: 1; min-width: 70px; padding: 2px 0; }

/* ─── Specs ────────────────────────────────────────── */
.specs-list { display: flex; flex-direction: column; gap: 5px; }
.specs-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; align-items: center; }
.specs-row input { font-size: 12px; padding: 6px 8px; }
.specs-add-btn { font-size: 11.5px; color: var(--accent); cursor: pointer; padding: 5px 0; display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.specs-add-btn:hover { text-decoration: underline; }

/* ─── Section Divider ──────────────────────────────── */
.form-section { margin: 18px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border-primary); }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.form-section-desc { font-size: 10.5px; color: var(--text-tertiary); margin-top: 1px; }

/* ─── Full Page Form ───────────────────────────────── */
.full-form { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-xl); padding: 22px; box-shadow: var(--shadow-card); }
.full-form-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.full-form-title { font-size: 17px; font-weight: 700; }
.full-form-actions { display: flex; gap: 8px; }

/* ─── Color & Date ─────────────────────────────────── */
input[type="color"].form-input { height: 40px; padding: 3px; cursor: pointer; }
input[type="date"].form-input, input[type="datetime-local"].form-input { color-scheme: dark; }
input[type="url"].form-input { direction: ltr; }

/* ─── Toast Notifications ──────────────────────────── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
[dir="rtl"] .toast-container { right: auto; left: 16px; }
.toast { background: var(--bg-card); border: 1px solid var(--border-secondary); border-radius: var(--radius-md); padding: 12px 16px; font-size: 12.5px; box-shadow: var(--shadow-lg); animation: slideInRight 300ms var(--ease-bounce); pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 320px; }
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }
[dir="rtl"] .toast.success { border-left: none; border-right: 3px solid var(--success); }
[dir="rtl"] .toast.warning { border-left: none; border-right: 3px solid var(--warning); }
[dir="rtl"] .toast.error { border-left: none; border-right: 3px solid var(--danger); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
[dir="rtl"] @keyframes slideInRight { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Empty State ──────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; color: var(--text-secondary); max-width: 320px; margin-bottom: 16px; }

/* ─── Animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(-16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }

.animate-in { animation: fadeIn 350ms var(--ease) both; }
.animate-slide { animation: slideIn 300ms var(--ease) both; }
.skeleton { background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%); background-size: 400px 100%; animation: shimmer 1.5s infinite linear; border-radius: var(--radius-sm); }

/* ─── Spinner ──────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-secondary); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); z-index: 200; box-shadow: none; }
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .header-search { width: 180px; }
  .main-content { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  #mobile-menu-btn { display: flex !important; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  .header-search { display: none; }
  .header-user-info { display: none; }
}

/* ─── Utilities ─────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Entry Page (Strapi-style Full-Page Form) ─────── */
.entry-page { max-width: 1400px; }
.entry-breadcrumb { margin-bottom: 12px; }
.entry-breadcrumb a { font-size: 13px; transition: opacity .2s; }
.entry-breadcrumb a:hover { opacity: .8; }

.entry-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-primary); }
.entry-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.3px; }
.entry-subtitle { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
.entry-header-actions { display: flex; gap: 8px; }

.entry-body { display: grid; grid-template-columns: 200px 1fr 260px; gap: 20px; align-items: start; }

/* Left Tab Sidebar */
.entry-sidebar { position: sticky; top: 16px; background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 8px; border: 1px solid var(--border-primary); }
.entry-tab { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-md); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: all .2s var(--ease); position: relative; }
.entry-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.entry-tab.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(29,78,216,.3); }
.entry-tab-icon { font-size: 16px; flex-shrink: 0; }
.entry-tab-label { white-space: nowrap; }

/* Center Form */
.entry-form { background: var(--bg-secondary); border-radius: var(--radius-lg); border: 1px solid var(--border-primary); padding: 28px; min-height: 500px; overflow-y: auto; }
.entry-panel { display: none; animation: fadeSlideUp .3s var(--ease); }
.entry-panel.active { display: block; }

.entry-section-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.entry-section-desc { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 18px; }

.entry-sub-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-primary); }
.entry-sub-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }

.entry-info-box { background: var(--bg-tertiary); border: 1px solid var(--border-primary); border-radius: var(--radius-md); padding: 16px; }

/* Right Info Panel */
.entry-info-panel { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.entry-info-card { background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: var(--radius-lg); padding: 16px; }
.entry-info-card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); margin-bottom: 10px; }
.entry-info-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-primary); font-size: 12.5px; }
.entry-info-row:last-child { border-bottom: none; }

/* Toast Notifications */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 99999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
[dir="rtl"] .toast-container { right: auto; left: 20px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: var(--radius-md); padding: 12px 18px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.3); animation: slideInRight .35s var(--ease); transition: all .3s var(--ease); min-width: 260px; }
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
[dir="rtl"] .toast.success { border-left: none; border-right: 3px solid var(--success); }
[dir="rtl"] .toast.warning { border-left: none; border-right: 3px solid var(--warning); }
[dir="rtl"] .toast.error { border-left: none; border-right: 3px solid var(--danger); }
[dir="rtl"] .toast.info { border-left: none; border-right: 3px solid var(--info); }

@keyframes slideInRight { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Badge neutral variant */
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Responsive Entry Page */
@media (max-width: 1100px) {
  .entry-body { grid-template-columns: 180px 1fr; }
  .entry-info-panel { display: none; }
}
@media (max-width: 768px) {
  .entry-body { grid-template-columns: 1fr; }
  .entry-sidebar { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 6px; }
  .entry-tab-label { display: none; }
  .entry-tab.active .entry-tab-label { display: inline; }
  .entry-header { flex-direction: column; gap: 12px; align-items: stretch; }
  .entry-header-actions { justify-content: flex-end; }
  .entry-form { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ─── Print ─────────────────────────────────────────── */
@media print {
  .sidebar, .header, .modal-overlay, .toast-container { display: none !important; }
  .app-layout { grid-template-columns: 1fr !important; grid-template-areas: "main" !important; }
  .main-content { overflow: visible !important; }
}



/* ═══ STATS GRID (new premium cards) ═══ */
.stats-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
  background: var(--accent-subtle, rgba(29,78,216,.12));
  color: var(--primary);
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}
.stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ═══ ENHANCED TABLE TOOLBAR ═══ */
.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-primary);
  gap: 12px;
}
.data-table-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══ BADGE ADDITIONS ═══ */
.badge-info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-purple { background: rgba(19,49,92, 0.15); color: #13315C; }

/* ═══ PWA INSTALL BANNER ═══ */
.pwa-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg, 12px);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  z-index: 10000;
  transition: transform .4s cubic-bezier(.4,0,.2,1);
  max-width: 420px;
}
.pwa-banner.show { transform: translateX(-50%) translateY(0); }
.pwa-banner-icon { font-size: 32px; flex-shrink: 0; }
.pwa-banner-text { flex: 1; }
.pwa-banner-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.pwa-banner-desc { font-size: 12px; color: var(--text-secondary); }
.pwa-banner-actions { display: flex; gap: 8px; }
.pwa-banner-dismiss { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 12px; padding: 6px 12px; border-radius: 6px; }
.pwa-banner-dismiss:hover { background: var(--bg-tertiary); }
.pwa-banner-install { background: var(--primary); color: #fff; border: none; padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; }
.pwa-banner-install:hover { filter: brightness(1.1); }

/* ═══ OFFLINE INDICATOR ═══ */
.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #B45309, #92400E);
  color: #fff;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  z-index: 100000;
  transform: translateY(-100%);
  transition: transform .3s ease;
}
.offline-bar.show { transform: translateY(0); }

/* ═══ SETTINGS PAGE TABS ═══ */
.settings-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-primary);
  margin-bottom: 20px;
  gap: 0;
}
.settings-tab {
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.settings-panel {
  display: none;
  animation: fadeIn .3s ease;
}
.settings-panel.active { display: block; }

/* ═══ SYSTEM INFO CARDS ═══ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.info-item {
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md, 8px);
  border-left: 3px solid var(--primary);
}
[dir="rtl"] .info-item { border-left: none; border-right: 3px solid var(--primary); }
.info-item-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.info-item-value {
  font-size: 14px;
  font-weight: 700;
}

/* ═══ RESPONSIVE STAT GRIDS ═══ */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .stat-card .stat-value { font-size: 22px; }
  .info-grid { grid-template-columns: 1fr; }
  .pwa-banner { left: 12px; right: 12px; transform: translateX(0) translateY(120px); max-width: none; }
  .pwa-banner.show { transform: translateX(0) translateY(0); }
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Full device support
   ═══════════════════════════════════════════════════════ */

/* ─── Tablet (max-width: 1024px) ─── */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-area { margin-left: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .data-table-toolbar { flex-wrap: wrap; gap: 8px; }
  .form-row { flex-direction: column; }
  .modal { max-width: 90vw !important; }
}

/* ─── Mobile (max-width: 768px) ─── */
@media (max-width: 768px) {
  /* Sidebar: hidden by default, overlay on toggle */
  .sidebar {
    position: fixed;
    left: -280px;
    width: 280px;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { left: 0; }
  .main-area { margin-left: 0 !important; }

  /* Top bar */
  .topbar { padding: 8px 12px; }
  .topbar-right { gap: 6px; }
  .topbar-right .lang-btn { display: none; }
  .topbar .search-bar { max-width: 160px; }

  /* Content */
  .main-content { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header h1 { font-size: 20px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .stat-card { padding: 12px !important; }
  .stat-card-value, .stat-card .stat-value { font-size: 20px !important; }
  .stat-card-label { font-size: 11px !important; }

  /* Tables: horizontal scroll - but ONLY on cards that actually hold a table.
     Blanket overflow-x:auto turned every card into a clipping box on both axes
     (per spec, one auto axis converts the other from visible), which cut off every
     dropdown, tooltip and popover rendered inside a card on a phone. */
  .card:has(> table), .card:has(> .data-table), .card:has(> .scroll > table) { overflow-x: auto; }
  .data-table { min-width: 600px; font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; white-space: nowrap; }
  .data-table-toolbar { flex-direction: column; }
  .data-table-toolbar .search-input { width: 100%; }

  /* Buttons: touch friendly */
  .btn { min-height: 40px; padding: 8px 16px; font-size: 13px; }
  .btn-sm { min-height: 34px; padding: 6px 12px; }

  /* Forms */
  .form-row { flex-direction: column; }
  .form-group { margin-bottom: 12px; }
  .form-input, .form-select, select.form-input { font-size: 16px !important; min-height: 42px; }

  /* Modal */
  .modal-overlay { padding: 8px; }
  .modal { max-width: 100% !important; max-height: 95vh !important; border-radius: 12px; }
  .modal-header { padding: 12px 16px; }
  .modal-header h3 { font-size: 16px; }

  /* POS Grid */
  #pos-products { grid-template-columns: repeat(2, 1fr) !important; }

  /* Mobile sidebar toggle button */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
  }

  /* Hide collapse button on mobile */
  .sidebar-collapse-btn { display: none; }
}

/* ─── Small Mobile (max-width: 480px) ─── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .stat-card { padding: 10px !important; }
  .stat-card-value, .stat-card .stat-value { font-size: 18px !important; }
  
  .page-header h1 { font-size: 18px; }
  .main-content { padding: 8px; }
  
  .topbar .search-bar { display: none; }
  .modal { margin: 4px; }
  
  /* Stack POS layout */
  #pos-products { grid-template-columns: repeat(2, 1fr) !important; }
  
  /* Table compact */
  .data-table { min-width: 500px; font-size: 11px; }
  .data-table th, .data-table td { padding: 6px 8px; }
}

/* ─── Large Desktop (min-width: 1400px) ─── */
@media (min-width: 1400px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .main-content { max-width: 1400px; margin: 0 auto; }
}

/* ─── Print Styles ─── */
@media print {
  .sidebar, .topbar, .btn, .mobile-menu-btn { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .main-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .data-table { min-width: auto; }
}

/* ─── Touch Improvements ─── */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .sidebar-item { min-height: 44px; padding: 10px 16px; }
  .form-input { min-height: 44px; }
  .data-table td { padding: 10px 12px; }
}

/* ─── Sidebar overlay backdrop ─── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.active { display: block; }

/* ─── Mobile menu button (hidden on desktop) ─── */
.mobile-menu-btn { display: none; }

/* ─── Show mobile menu button on small screens ─── */
@media (max-width: 768px) {
  #mobile-menu-btn { display: flex !important; }
  .header-left { gap: 8px; }
}
