/* ================================================================
   NexPOS — Main CSS Design System
   ================================================================ */

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

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-primary);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  overflow: hidden;
  height: 100vh;
}

body[dir="rtl"] { font-family: var(--font-arabic); }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, select, textarea { font-family: inherit; outline: none; }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Layout ───────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  transition: width 0.3s ease, min-width 0.3s ease;
  position: relative; z-index: 100; overflow: hidden;
}

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

.sidebar.collapsed { width: 64px; min-width: 64px; }

.sidebar-logo {
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-color);
  height: 64px; min-height: 64px; overflow: hidden;
}

.sidebar-logo .logo-hex {
  width: 36px; height: 36px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-logo .logo-hex svg { width: 20px; height: 20px; color: white; }

.sidebar-logo .logo-text {
  font-size: 1.3rem; font-weight: 800; white-space: nowrap;
  color: white; opacity: 1; transition: opacity 0.2s;
}

.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0;
  scrollbar-width: thin; scrollbar-color: var(--border-color) transparent;
  opacity: 0;
  transition: opacity 0.12s ease-in;
}

.sidebar-nav.ready {
  opacity: 1;
}

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 10px 16px 4px; white-space: nowrap; overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-group-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 16px; border-radius: 10px; margin: 2px 8px;
  cursor: pointer; transition: all 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
  white-space: nowrap; overflow: hidden; position: relative;
  color: var(--text-secondary); font-size: 0.86rem; font-weight: 600;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.18) 0%, rgba(239, 68, 68, 0.05) 100%);
  color: #ffffff;
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.22);
  transform: translateX(5px) scale(1.02);
}

body[dir="rtl"] .nav-item:hover {
  transform: translateX(-5px) scale(1.02);
  background: linear-gradient(-90deg, rgba(239, 68, 68, 0.18) 0%, rgba(239, 68, 68, 0.05) 100%);
}

.nav-item:hover .nav-icon {
  transform: scale(1.22);
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.7));
  color: var(--primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.28) 0%, rgba(239, 68, 68, 0.1) 100%);
  color: var(--primary);
  font-weight: 800;
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.28);
}

.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.9));
  transform: scale(1.15);
  color: var(--primary);
}

.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 15%; bottom: 15%;
  width: 4px;
  background: linear-gradient(to bottom, #ef4444, #f97316);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

body[dir="rtl"] .nav-item.active::before {
  left: auto; right: 0; border-radius: 4px 0 0 4px;
}

.nav-icon { width: 19px; height: 19px; flex-shrink: 0; transition: transform 0.22s cubic-bezier(0.34, 1.3, 0.64, 1), filter 0.22s ease; }
.nav-label { transition: opacity 0.2s, color 0.2s; font-size: 0.84rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }

.nav-badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 0.62rem; font-weight: 800; padding: 2px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.sidebar.collapsed .nav-badge { opacity: 0; }

.nav-submenu { display: none; padding-left: 8px; margin: 2px 0 4px 0; }
.nav-submenu.open { display: block; }
.nav-submenu .nav-item {
  font-size: 0.81rem;
  padding: 8px 14px;
  margin: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.nav-submenu .nav-item:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.3);
}

.nav-arrow { margin-left: auto; width: 14px; height: 14px; transition: transform 0.2s, opacity 0.2s; flex-shrink: 0; }
.nav-item.open .nav-arrow { transform: rotate(90deg); }
.sidebar.collapsed .nav-arrow { opacity: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Top Bar ──────────────────────────────────────────────────── */
.topbar {
  height: 60px; min-height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.topbar-breadcrumb { font-size: 0.75rem; color: var(--text-muted); }

/* ── Main Content ─────────────────────────────────────────────── */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-base); height: 100vh; max-height: 100vh; }
.main-content, .page-content { flex: 1; overflow-y: auto !important; overflow-x: hidden; padding: 20px 20px 80px; scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; min-height: 0; -webkit-overflow-scrolling: touch; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 20px; transition: box-shadow 0.2s;
}

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

.card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}

.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 0.82rem; font-weight: 600;
  transition: all 0.15s ease; white-space: nowrap; font-family: inherit; cursor: pointer; border: none;
}

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

.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px var(--primary-shadow); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

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

.btn-success { background: var(--success); color: white; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: white; box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-warning { background: var(--warning); color: #1a1a1a; box-shadow: 0 2px 8px rgba(245,158,11,0.3); }
.btn-warning:hover { background: #d97706; }

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

.btn-icon { padding: 8px; border-radius: 8px; background: transparent; color: var(--text-secondary); transition: all 0.15s; }
.btn-icon:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-icon svg { width: 17px; height: 17px; }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 12px 24px; font-size: 0.9rem; }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

/* ── Form Elements ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.03em;
}

.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--input-bg); border: 1px solid var(--border-color);
  border-radius: 8px; color: var(--text-primary); font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-alpha); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  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='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}

body[dir="rtl"] select.form-control { background-position: left 10px center; padding-right: 12px; padding-left: 30px; }

.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: 8px 0 0 8px; border-right: none; flex: 1; }
body[dir="rtl"] .input-group .form-control { border-radius: 0 8px 8px 0; border-right: 1px solid var(--border-color); border-left: none; }

.input-group-addon {
  padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border-color);
  border-radius: 0 8px 8px 0; color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; white-space: nowrap;
  display: flex; align-items: center;
}

body[dir="rtl"] .input-group-addon { border-radius: 8px 0 0 8px; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-color); }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

thead th {
  background: var(--surface-2); color: var(--text-secondary); font-weight: 600;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap;
}

body[dir="rtl"] thead th { text-align: right; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover-bg); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-primary   { background: var(--primary-alpha); color: var(--primary); }
.badge-success   { background: rgba(16,185,129,0.15); color: #10b981; }
.badge-danger    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-warning   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-secondary { background: var(--surface-2); color: var(--text-secondary); }
.badge-info      { background: rgba(99,102,241,0.15); color: #6366f1; }

/* ── Stat Cards ───────────────────────────────────────────────── */
.stat-card {
  background: var(--surface); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
  position: relative; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%;
}

body[dir="rtl"] .stat-card::after { right: auto; left: 0; }

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

.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.primary { background: var(--primary-alpha); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,0.15); color: #10b981; }
.stat-icon.warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.stat-icon.danger  { background: rgba(239,68,68,0.15);  color: #ef4444; }
.stat-icon.purple  { background: rgba(139,92,246,0.15); color: #8b5cf6; }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.stat-change { font-size: 0.72rem; font-weight: 600; margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-change svg { width: 12px; height: 12px; }

/* ── Grid ─────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}

.modal-overlay.open, .modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface); border: 1px solid var(--border-color);
  border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh;
  display: flex; flex-direction: column;
  transform: scale(0.95) translateY(10px); transition: transform 0.2s;
  box-shadow: var(--shadow-xl);
}

.modal-overlay.open .modal, .modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

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

.modal-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border-color); gap: 0; overflow-x: auto; scrollbar-width: none; }
.tab-item {
  padding: 10px 18px; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: color 0.15s, border-color 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-item svg { width: 14px; height: 14px; }
.tab-content { display: none; padding-top: 16px; }
.tab-content.active { display: block; }

/* ── Search ───────────────────────────────────────────────────── */
.search-bar { position: relative; display: flex; align-items: center; }
.search-bar svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
body[dir="rtl"] .search-bar svg { left: auto; right: 10px; }
.search-bar input { padding-left: 34px; }
body[dir="rtl"] .search-bar input { padding-left: 12px; padding-right: 34px; }

/* ── Toggle ───────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border-color); border-radius: 22px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Toast ────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}

body[dir="rtl"] #toast-container { right: auto; left: 16px; }

.toast {
  background: var(--surface); border: 1px solid var(--border-color); border-radius: 10px;
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 0.82rem; font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: all;
  animation: toastIn 0.3s ease forwards; min-width: 260px; max-width: 360px;
}

.toast.exit { animation: toastOut 0.3s ease forwards; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--primary); }

@keyframes toastIn  { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); }   to { opacity: 0; transform: translateX(30px); } }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-color); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.8rem; }

/* ── Divider ──────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-color); margin: 16px 0; }

/* ── Flex Utilities ───────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; } .flex-wrap { flex-wrap: wrap; }

/* ── Spacing ──────────────────────────────────────────────────── */
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-5{margin-bottom:20px}
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.p-0{padding:0}

/* ── Text Utilities ───────────────────────────────────────────── */
.text-primary-color { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-sm { font-size: 0.75rem; }
.text-xs { font-size: 0.68rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dropdown ─────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border-color);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); min-width: 210px;
  z-index: 999999; opacity: 0; pointer-events: none;
  transform: translateY(-8px); transition: opacity 0.15s ease, transform 0.15s ease; overflow: hidden;
}
body[dir="rtl"] .dropdown-menu { right: auto !important; left: 0 !important; }
.dropdown.open > .dropdown-menu,
.dropdown-menu.open {
  opacity: 1 !important;
  pointer-events: all !important;
  transform: translateY(0) !important;
  display: block !important;
}
.dropdown-item { padding: 9px 14px; font-size: 0.82rem; color: var(--text-primary); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background 0.1s; }
.dropdown-item:hover { background: var(--hover-bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ── DataGridView Sortable Table Headers & Column Picker ─────── */
th.sortable-th {
  cursor: pointer !important;
  user-select: none;
  transition: all 0.15s ease;
  position: relative;
  white-space: nowrap;
}
th.sortable-th:hover {
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--primary) !important;
}
th.sortable-th::after {
  content: " ⇅";
  opacity: 0.35;
  font-size: 0.75rem;
  margin-left: 4px;
  display: inline-block;
  vertical-align: middle;
}
body[dir="rtl"] th.sortable-th::after {
  margin-left: 0;
  margin-right: 4px;
}
th.sortable-th.sort-asc::after {
  content: " ▲" !important;
  opacity: 1 !important;
  color: #3b82f6 !important;
  font-weight: 900;
}
th.sortable-th.sort-desc::after {
  content: " ▼" !important;
  opacity: 1 !important;
  color: #ef4444 !important;
  font-weight: 900;
}

.col-picker-menu {
  max-height: 380px;
  overflow-y: auto;
  padding: 10px 12px;
  min-width: 240px;
}
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s;
}
.col-picker-item:hover {
  background: var(--hover-bg);
}
.col-picker-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header-left h1 { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 2px; }
.page-header-left p { font-size: 0.78rem; color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--surface-2); border-radius: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 0.78rem; font-weight: 600; cursor: pointer; background: var(--surface); border: 1px solid var(--border-color); color: var(--text-secondary); transition: all 0.15s; }
.page-btn:hover { background: var(--hover-bg); color: var(--text-primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Num Input ────────────────────────────────────────────────── */
.num-input-wrap { display: flex; align-items: center; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--input-bg); }
.num-input-wrap input { border: none; background: transparent; text-align: center; width: 60px; padding: 8px 4px; color: var(--text-primary); font-size: 0.85rem; font-weight: 600; }
.num-btn { padding: 8px 10px; background: var(--surface-2); color: var(--text-primary); font-size: 1rem; font-weight: 700; cursor: pointer; user-select: none; transition: background 0.1s; border: none; }
.num-btn:hover { background: var(--hover-bg); }

/* ── Status Dot ───────────────────────────────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.active   { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.status-dot.inactive { background: var(--text-muted); }
.status-dot.warning  { background: var(--warning); }
.status-dot.danger   { background: var(--danger); }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-fade  { animation: fadeIn 0.3s ease; }
.animate-slide { animation: slideUp 0.3s ease; }
.animate-pulse { animation: pulse 1.5s ease infinite; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Sidebar Mobile Backdrop ─────────────────────────────────── */
#sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 490;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ── Universal Picture & Image Scaling ───────────────────────── */
img, .product-img, .item-img, .category-img, .table-img {
  max-width: 100%;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
}
.pos-product-card .product-img,
.product-card-img-wrap img {
  width: 100%;
  height: 105px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}

/* ── Responsive Breakpoints System ────────────────────────────── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 1.3rem; }
}

@media (max-width: 992px) {
  /* Off-canvas mobile drawer sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 270px;
    transform: translateX(-100%);
    z-index: 500;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  body[dir="rtl"] .sidebar, html[dir="rtl"] .sidebar {
    left: auto !important;
    right: 0 !important;
    transform: translateX(100%) !important;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.4) !important;
  }
  body[dir="rtl"] .sidebar.open, html[dir="rtl"] .sidebar.open {
    transform: translateX(0) !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 14px;
    width: 100%;
  }

  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }

  .topbar-right .btn-hide-sm, .topbar-right .btn-hide-mobile {
    display: none !important;
  }
}

/* ── Responsive POS Workspace Layout ─────────────────────────── */
.pos-main-split {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.pos-items-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  min-width: 0;
}

.pos-cart-col {
  width: 380px;
  min-width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 15;
}

body[dir="rtl"] .pos-cart-col {
  border-left: none;
  border-right: 1px solid var(--border-color);
}

.pos-mobile-nav {
  display: none;
}

.pos-mobile-float-bar {
  display: none;
}

.pos-mobile-back-to-catalog {
  display: none;
}

@media (max-width: 768px) {
  .topbar {
    padding: 8px 12px;
    min-height: 52px;
  }
  .topbar-title {
    font-size: 0.92rem;
  }
  .breadcrumb {
    display: none !important;
  }
  .page-content {
    padding: 10px 8px;
  }
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 {
    grid-template-columns: 1fr;
  }
  .stat-card {
    padding: 12px 14px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .toolbar > div {
    width: 100%;
    justify-content: space-between;
  }
  .search-bar {
    width: 100% !important;
    min-width: 100% !important;
  }
  .modal-dialog {
    max-width: 95% !important;
    margin: 16px auto !important;
  }
  .modal-body {
    padding: 16px !important;
  }
  .modal-footer {
    padding: 12px 16px !important;
  }
  
  /* Touch Targets Optimization */
  .btn, .tab-btn, .category-btn, .pos-cat-pill, .nav-item {
    min-height: 42px;
  }
  .pos-product-card {
    padding: 10px !important;
  }
  .pos-product-card .product-img {
    height: 85px;
  }

  /* Table & Dining Floor responsive cards */
  .restaurant-floor-grid, #tables-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* Mobile POS Switcher & Dynamic Layout */
  #pos-root {
    position: relative;
    height: 100% !important;
  }

  .pos-mobile-nav {
    display: flex !important;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 10px;
    gap: 8px;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  }

  .pos-mobile-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
  }

  .pos-mobile-tab.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.35);
  }

  .pos-mobile-tab .badge {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.72rem;
  }

  .pos-mobile-tab .pos-mobile-cart-total {
    font-weight: 800;
  }

  /* Catalog vs Cart Switch in Mobile */
  #pos-root.mobile-show-catalog .pos-items-col {
    display: flex !important;
    width: 100% !important;
    flex: 1 !important;
  }
  #pos-root.mobile-show-catalog .pos-cart-col {
    display: none !important;
  }

  #pos-root.mobile-show-cart .pos-items-col {
    display: none !important;
  }
  #pos-root.mobile-show-cart .pos-cart-col {
    display: flex !important;
    width: 100% !important;
    min-width: 100% !important;
    flex: 1 !important;
    border: none !important;
  }

  .pos-mobile-back-to-catalog {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    background: var(--surface-2);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
  }

  /* Sticky floating checkout button on bottom of catalog */
  .pos-mobile-float-bar {
    position: absolute;
    bottom: 14px;
    left: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    cursor: pointer;
    font-weight: 800;
  }

  /* Items Grid on Mobile */
  #pos-items-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 8px !important;
    padding-bottom: 80px !important;
  }

  .pos-item-card {
    padding: 8px !important;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 6px 8px;
  }
  .topbar-right {
    gap: 4px;
  }
  .btn-icon {
    width: 34px;
    height: 34px;
  }
  .restaurant-floor-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .table-wrapper {
    font-size: 0.76rem;
  }
}


/* ── Doc / Print Layout (used for A4 previews) ─────────────────── */
.doc-a4 {
  width: 210mm; min-height: 297mm; background: white; color: #111;
  padding: 16mm; margin: 0 auto;
  font-family: 'Inter', 'Cairo', sans-serif; font-size: 13px;
  box-shadow: 0 0 20px rgba(0,0,0,0.15);
}
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #0055CC; }
.doc-company-info h2 { font-size: 22px; font-weight: 800; color: #0055CC; }
.doc-title-block { text-align: right; }
.doc-title-block h1 { font-size: 28px; font-weight: 800; color: #111; margin-bottom: 4px; }
.doc-number { font-size: 14px; color: #0055CC; font-weight: 700; }
.doc-date { font-size: 12px; color: #888; }
.doc-parties { display: flex; gap: 20px; margin-bottom: 20px; }
.doc-party { flex: 1; background: #f8f9fc; border-radius: 8px; padding: 12px; }
.doc-party h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-bottom: 6px; }
.doc-party p { font-weight: 600; }
.doc-party span { font-size: 12px; color: #666; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12px; }
.doc-table th { background: #0055CC; color: white; padding: 8px 10px; text-align: left; }
.doc-table td { padding: 7px 10px; border-bottom: 1px solid #eee; }
.doc-table tr:nth-child(even) td { background: #f8f9fc; }
.doc-table .total-row td { font-size: 15px; font-weight: 800; background: #f0f4ff; padding-top: 10px; border-top: 2px solid #0055CC; }
.doc-totals { display: flex; justify-content: flex-end; }
.doc-totals table { width: 240px; }
.doc-totals td { padding: 4px 8px; font-size: 13px; }
.doc-totals tr:last-child td { font-size: 16px; font-weight: 800; color: #0055CC; border-top: 2px solid #0055CC; padding-top: 8px; }
.doc-footer { display: flex; justify-content: space-between; align-items: flex-end; padding-top: 16px; border-top: 1px solid #eee; font-size: 11px; color: #888; }
.doc-footer-section h4 { color: #111; font-size: 12px; margin-bottom: 4px; }
.doc-signature { border-top: 1px solid #ccc; width: 120px; padding-top: 4px; text-align: center; font-size: 10px; color: #888; }

/* ── Invoice Designer Scrollable Controls ─────────────────────── */
.inv-designer-controls-col {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  scroll-behavior: smooth;
}
.inv-designer-controls-col::-webkit-scrollbar {
  width: 6px;
}
.inv-designer-controls-col::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 6px;
}
.inv-designer-controls-col::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
/* ── Rich Visual Enhancements for All Tabs & Icons ───────────── */
.nav-item, .tab, .tab-btn, .category-btn, .pos-cat-pill, .btn-icon, .filter-pill {
  transition: all 0.24s cubic-bezier(0.34, 1.4, 0.64, 1) !important;
}

/* Category & Action Tabs Hover */
.category-btn:hover, .pos-cat-pill:hover, .tab-btn:hover {
  transform: translateY(-3px) scale(1.06) !important;
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35) !important;
  border-color: var(--primary) !important;
}

/* Topbar Icon Buttons */
.btn-icon:hover {
  transform: scale(1.15) !important;
  background: var(--hover-bg) !important;
  color: var(--primary) !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4) !important;
}

/* Tab and Navigation Label Zoom */
.nav-item:hover .nav-label {
  color: #ffffff !important;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

/* POS Screen Cart and Pay Button Hover */
.btn-primary:hover {
  transform: translateY(-2px) scale(1.02) !important;
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5) !important;
}

.btn-secondary:hover {
  transform: translateY(-2px) scale(1.02) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3) !important;
}

/* ── Restaurant Full-Page Hub & Delivery Dispatch ─────────────── */
.restaurant-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}
.restaurant-nav-pill:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  transform: translateY(-2px);
  border-color: rgba(239, 68, 68, 0.4);
}
.restaurant-nav-pill.active {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}
.restaurant-nav-pill .badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 900;
}
.restaurant-nav-pill.active .badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.delivery-order-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  transition: all 0.22s ease;
  box-shadow: var(--shadow-sm);
}
.delivery-order-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(239, 68, 68, 0.35);
}

.sla-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}
.sla-badge-normal {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.sla-badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.sla-badge-urgent {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  animation: urgentPulse 1.8s infinite ease-in-out;
}
@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.pay-badge-paid {
  background: rgba(16, 185, 129, 0.16);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.pay-badge-unpaid {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.restaurant-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.restaurant-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.5;
}
.restaurant-step.active {
  color: var(--primary);
  font-weight: 900;
  opacity: 1;
}
.restaurant-step.completed {
  color: var(--success);
  opacity: 0.9;
}

