/* ═══════════════════════════════════════════════════════════════════
   Orbit Grocery POS — Global Theme (v2 — Polished)
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --card: #1e293b;
  --border: #334155;
  --primary: #059669;
  --primary-hover: #047857;
  --accent: #10b981;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Auth Gate ─────────────────────────────────────────────────── */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #064e3b 0%, #0f172a 50%, #1e1b4b 100%);
  animation: gradientShift 8s ease infinite alternate;
}
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 48px 40px;
  width: 400px;
  text-align: center;
  box-shadow: var(--shadow), 0 0 80px rgba(16,185,129,0.08);
  border: 1px solid var(--border);
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  width: 80px; height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 32px rgba(5,150,105,0.3);
}
.auth-logo .material-icons-round { font-size: 40px; color: white; }

.auth-card h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}
.auth-card > p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-shortcuts {
  display: flex; justify-content: center; gap: 16px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.auth-shortcuts span {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}

.input-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}
.input-group input, .role-select {
  width: 100%;
  padding: 12px 44px 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'Tajawal', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.15);
}
.input-icon {
  position: absolute;
  right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); font-size: 20px;
  pointer-events: none;
}
.role-select {
  padding: 12px 16px;
  cursor: pointer;
  appearance: none;
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none; border-radius: 12px;
  font-family: 'Tajawal'; font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(5,150,105,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-family: 'Tajawal'; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  background: var(--danger); color: white;
  border: none; border-radius: 12px;
  font-family: 'Tajawal'; font-size: 14px; font-weight: 600;
  cursor: pointer; margin-top: 12px;
  transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.9; }

.btn-icon {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 6px; border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.btn-icon:hover { background: var(--border); color: var(--text); }

.btn-login { margin-top: 8px; }

/* Shortcut key badges */
.shortcut-key {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  color: var(--text-secondary);
  margin-right: auto;
}
.shortcut-key.light {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
}

/* ─── Main Layout ──────────────────────────────────────────────── */
.main-app {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 10;
}
.sidebar-header {
  padding: 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 28px; color: var(--accent); }
.sidebar-title { font-size: 17px; font-weight: 800; }

.sidebar-nav {
  flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 16px;
  background: none; border: none; border-radius: 12px;
  color: var(--text-secondary);
  font-family: 'Tajawal'; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.nav-item:hover { background: rgba(5,150,105,0.08); color: var(--text); }
.nav-item.active {
  background: rgba(5,150,105,0.15);
  color: var(--accent);
}
.nav-item .material-icons-round { font-size: 22px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-info .material-icons-round { font-size: 32px; color: var(--accent); }
.user-name { display: block; font-size: 13px; font-weight: 700; }
.user-role { display: block; font-size: 11px; color: var(--text-secondary); }
.btn-logout {
  background: none; border: none; color: var(--danger);
  cursor: pointer; padding: 8px; border-radius: 10px;
  transition: background 0.2s;
}
.btn-logout:hover { background: rgba(239,68,68,0.12); }

/* ─── Content ──────────────────────────────────────────────────── */
.content {
  flex: 1; overflow-y: auto; padding: 0;
}
.page { display: none; padding: 24px; height: 100%; }
.page.active { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 800; }

/* ─── POS Layout ───────────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - 48px);
}
.pos-products { overflow-y: auto; }

.pos-search {
  position: relative; margin-bottom: 14px;
}
.pos-search input {
  width: 100%; padding: 12px 44px 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-family: 'Tajawal'; font-size: 14px;
  outline: none; transition: border-color 0.2s;
}
.pos-search input:focus { border-color: var(--primary); }
.search-icon {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); pointer-events: none;
}

.category-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.cat-tab {
  padding: 8px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-secondary);
  font-family: 'Tajawal'; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.cat-tab.active, .cat-tab:hover {
  background: var(--primary); color: white; border-color: var(--primary);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: all 0.2s; text-align: center;
  position: relative;
}
.product-card:hover {
  border-color: var(--primary); transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(5,150,105,0.15);
}
.product-card .product-emoji { font-size: 36px; margin-bottom: 8px; }
.product-card .product-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.product-card .product-card-price {
  font-family: 'Inter'; font-size: 16px; font-weight: 800; color: var(--accent);
}
.product-card.out-of-stock { opacity: 0.4; pointer-events: none; }
.product-card.out-of-stock::after {
  content: 'نفذ'; display: block;
  font-size: 11px; color: var(--danger); margin-top: 4px; font-weight: 700;
}

.stock-badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px;
}
.stock-badge.low {
  background: rgba(245,158,11,0.15); color: var(--warning);
}

/* ─── Cart ─────────────────────────────────────────────────────── */
.pos-cart {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 48px);
}
.cart-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cart-header h3 { font-size: 16px; font-weight: 700; }
.cart-header .material-icons-round:first-child { color: var(--accent); }

.cart-badge {
  display: flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--accent); color: white;
  border-radius: 11px; font-family: 'Inter';
  font-size: 12px; font-weight: 700;
}

.cart-items { flex: 1; overflow-y: auto; padding: 12px; }
.cart-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 200px;
  color: var(--text-secondary);
}
.cart-empty .material-icons-round { font-size: 48px; margin-bottom: 12px; }

.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  background: var(--bg); margin-bottom: 8px;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 14px; font-weight: 600; }
.cart-item-price { font-size: 12px; color: var(--text-secondary); }
.cart-item-qty {
  display: flex; align-items: center; gap: 6px;
}
.cart-item-qty button {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--border); border: none; color: white;
  cursor: pointer; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.cart-item-qty button:hover { background: var(--primary); }
.cart-item-qty span { font-family: 'Inter'; font-weight: 700; min-width: 24px; text-align: center; }
.cart-item-total {
  font-family: 'Inter'; font-weight: 700; color: var(--accent); min-width: 60px;
  text-align: left;
}
.cart-item-remove {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 4px; border-radius: 6px;
  transition: all 0.2s; display: flex; align-items: center;
}
.cart-item-remove:hover { background: rgba(239,68,68,0.15); color: var(--danger); }
.cart-item-remove .material-icons-round { font-size: 18px; }

.cart-summary {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.summary-row {
  display: flex; justify-content: space-between;
  font-size: 14px; margin-bottom: 8px;
  color: var(--text-secondary);
}
.summary-row.total {
  font-size: 20px; font-weight: 800; color: var(--text);
  padding-top: 12px; border-top: 1px solid var(--border);
  margin-bottom: 14px;
}
.summary-row.total span:last-child { color: var(--accent); font-family: 'Inter'; }

.btn-checkout { width: 100%; padding: 14px; font-size: 16px; }

/* ─── Data Table ───────────────────────────────────────────────── */
.products-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 14px 16px; text-align: right;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  background: var(--bg);
}
.data-table td { font-size: 14px; }
.data-table tr:hover td { background: rgba(5,150,105,0.04); }

/* ─── Reports ──────────────────────────────────────────────────── */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.report-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color 0.2s;
}
.report-card:hover { border-color: rgba(255,255,255,0.1); }
.report-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.report-icon .material-icons-round { font-size: 26px; }
.report-value { display: block; font-family: 'Inter'; font-size: 24px; font-weight: 800; }
.report-label { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Settings ─────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.setting-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.setting-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.setting-card .input-group { margin-bottom: 12px; }
.setting-card input {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: 'Tajawal'; font-size: 14px;
}

/* ─── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}
.modal-content {
  position: relative; z-index: 101;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; width: 400px;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-content h3 { font-size: 18px; font-weight: 800; margin-bottom: 20px; }
.modal-content .input-group { margin-bottom: 14px; }
.modal-content input, .modal-content select {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: 'Tajawal'; font-size: 14px;
}
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

.receipt-content { max-width: 360px; }
.receipt-header {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-bottom: 16px;
}
.receipt-header .material-icons-round { color: var(--accent); font-size: 28px; }
#receipt-body {
  background: var(--bg); border-radius: 12px; padding: 16px;
  font-size: 13px; line-height: 1.8;
}
#receipt-body .receipt-line { display: flex; justify-content: space-between; }
#receipt-body .receipt-divider { border-top: 1px dashed var(--border); margin: 8px 0; }
#receipt-body .receipt-total { font-size: 18px; font-weight: 800; color: var(--accent); }

/* ─── Toast Notifications ──────────────────────────────────────── */
.toast-notification {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 12px 24px;
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
  font-family: 'Tajawal'; font-size: 14px; font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  pointer-events: none;
}
.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-notification .material-icons-round { font-size: 22px; }

.toast-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
}
.toast-error {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: white;
}
.toast-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: white;
}
.toast-info {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
}

/* ─── Date Filter ──────────────────────────────────────────────── */
.date-filter { display: flex; align-items: center; gap: 10px; }
.date-filter input {
  padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: 'Tajawal';
}
.date-filter label { color: var(--text-secondary); font-size: 13px; font-weight: 600; }

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { max-height: 50vh; }
  .page { height: auto; overflow-y: auto; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-title, .nav-item span:nth-child(2), .user-info div, .shortcut-key { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-header { justify-content: center; }
  .auth-card { width: 340px; padding: 36px 28px; }
  .auth-shortcuts { display: none; }
  .reports-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .reports-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

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