/* ===================================================================
   قەڵای عنتاب — Qalay Antap POS
   System-wide theme: Warm Amber + Charcoal
   This file is linked by every page, so the palette + components here
   propagate across the whole system.

   NOTE: every selector here is also used by the page files and their
   JavaScript. Class names are deliberately kept stable — restyle them,
   but do not rename or remove them.
=================================================================== */

/* ===== Design Tokens (change colors here once, everywhere updates) ===== */
:root {
  /* Brand palette */
  --amber:        #D97706;   /* primary accent */
  --amber-dark:   #B45309;
  --amber-light:  #FCD34D;
  --amber-soft:   #FEF3C7;   /* tinted backgrounds */
  --amber-tint:   #FFFBEB;   /* faintest wash — hover rows, stripes */

  --charcoal:     #1F2937;   /* dark surfaces / navbar */
  --charcoal-2:   #111827;   /* deepest */
  --ink:          #1C1917;   /* body text */

  --cream:        #FAF7F2;   /* page background */
  --surface:      #FFFFFF;   /* cards */
  --line:         #ECE7DE;   /* borders on cream */
  --line-2:       #E5E0D6;

  --green:        #16A34A;   /* money / success */
  --green-soft:   #DCFCE7;
  --red:          #DC2626;   /* danger / delete */
  --red-soft:     #FEE2E2;
  --muted:        #78716C;   /* secondary text */

  /* Typographic scale */
  --fs-sm:        13px;
  --fs-base:      14.5px;
  --fs-lg:        16px;
  --fs-title:     20px;

  /* Shape & depth */
  --radius:       16px;
  --radius-sm:    10px;
  --radius-pill:  999px;
  --shadow-sm:    0 1px 2px rgba(28, 25, 23, 0.04),
                  0 2px 8px rgba(31, 41, 55, 0.05);
  --shadow:       0 2px 4px rgba(28, 25, 23, 0.03),
                  0 8px 24px rgba(31, 41, 55, 0.07);
  --shadow-lg:    0 16px 40px rgba(31, 41, 55, 0.13);
  --shadow-amber: 0 6px 18px rgba(217, 119, 6, 0.26);
  --ring:         0 0 0 3px rgba(217, 119, 6, 0.20);
}

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

/* ===== Font ===== */
@font-face {
  font-family: "BahijSans";
  src: url("../fonts/BahijSans.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
}

/* ===== Base ===== */
body {
  font: var(--fs-base)/1.65 "BahijSans", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--amber-soft) 0%, transparent 60%),
    var(--cream);
  background-attachment: fixed;
  color: var(--ink);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Consistent text selection across the system */
::selection { background: var(--amber-soft); color: var(--amber-dark); }

/* Softer, on-brand scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ===== Layout ===== */
.container {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 24px;
  padding: 30px;
  max-width: 1200px;
  margin: auto;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  /* Only the shadow reacts — cards holding tables/forms must not shift
     under the cursor while you are reading or clicking a row. */
  transition: box-shadow 0.22s ease, border-color 0.22s ease;
}
.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--line-2);
}

/* ===== Headings ===== */
h2 {
  margin-bottom: 20px;
  font-weight: 800;
  font-size: var(--fs-title);
  letter-spacing: 0.2px;
  color: var(--charcoal);
  padding-bottom: 12px;
  position: relative;
  font-family: "BahijSans", sans-serif;
}
h2::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: 0;
  width: 56px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--amber), var(--amber-light));
}

/* ===== Labels & Inputs ===== */
label {
  font-weight: 600;
  margin: 14px 0 6px;
  display: block;
  color: var(--charcoal);
  font-size: var(--fs-sm);
  letter-spacing: 0.2px;
  font-family: "BahijSans", sans-serif;
}
input, button, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: var(--fs-base);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-family: "BahijSans", sans-serif;
}
input:hover, select:hover { border-color: var(--line-2); background: #fff; }
input:focus, select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: var(--ring);
}
input[readonly] {
  background: var(--cream);
  font-weight: 700;
  color: var(--charcoal);
  border-color: var(--line);
}
input[disabled] { background: #F5F5F4; color: var(--muted); cursor: not-allowed; }
input::placeholder { color: #A8A29E; }

/* Keyboard users (and barcode scanners) always get a visible target */
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ===== Buttons ===== */
button {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease,
              box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.primary {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-amber);
}
button.primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 26px rgba(217, 119, 6, 0.38);
}

button.outline {
  background: #fff;
  border: 1.5px solid var(--amber);
  color: var(--amber-dark);
}
button.outline:hover {
  background: var(--amber);
  color: #fff;
}

button.btn-danger,
.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
}
button.btn-danger:hover,
.btn-danger:hover { background: #B91C1C; }

/* Default (un-classed) buttons: subtle neutral */
button:not(.primary):not(.outline):not(.btn-danger) {
  background: #fff;
  border: 1px solid var(--line-2);
  color: var(--charcoal);
}
button:not(.primary):not(.outline):not(.btn-danger):hover {
  background: var(--charcoal);
  color: #fff;
  border-color: var(--charcoal);
}

/* ===== Rows & Grids ===== */
.row { display: flex; gap: 14px; }
.row > div { flex: 1; }

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  font-size: var(--fs-base);
}
.table th, .table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-family: "BahijSans", sans-serif;
}
.table thead {
  background: linear-gradient(135deg, var(--charcoal) 0%, var(--charcoal-2) 100%);
  color: #fff;
  font-size: var(--fs-sm);
}
.table thead th {
  font-weight: 700;
  letter-spacing: 0.3px;
  /* Column names stay visible while scrolling long lists */
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(135deg, var(--charcoal) 0%, var(--charcoal-2) 100%);
}
.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:nth-child(even) { background: #FCFBF9; }
.table tbody tr:hover { background: var(--amber-tint); }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td {
  font-weight: 800;
  background: var(--cream);
  color: var(--charcoal);
  font-size: var(--fs-lg);
  border-top: 2px solid var(--line-2);
}

/* Long tables scroll inside their card instead of stretching the page */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Utilities ===== */
.right { text-align: right; }

.badge {
  display: inline-block;
  border: 1px solid var(--amber);
  color: var(--amber-dark);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--amber-soft);
  font-family: "BahijSans", sans-serif;
  white-space: nowrap;
}
.badge.green { border-color: var(--green); color: #15803D; background: var(--green-soft); }
.badge.muted { border-color: var(--line-2); color: var(--muted); background: #fff; }

.small { font-size: var(--fs-sm); color: var(--muted); font-family: "BahijSans", sans-serif; }

/* ===== Flash / status messages ===== */
.msg, .flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  border: 1px solid var(--amber-light);
  color: var(--amber-dark);
  font-weight: 600;
}

/* ===== Pagination (used by renderPagination in db.php) ===== */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0 4px;
}
.pagination a {
  display: inline-block;
  min-width: 42px;
  text-align: center;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--charcoal);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: all 0.15s ease;
}
.pagination a:hover {
  border-color: var(--amber);
  color: var(--amber-dark);
  background: var(--amber-tint);
}
.pagination a.active {
  background: linear-gradient(135deg, var(--amber), var(--amber-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-amber);
}

/* ===== Shared Navbar (the include files reference these classes) ===== */
.navbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--charcoal) 0%, var(--charcoal-2) 100%);
  padding: 11px 22px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.20);
  border-bottom: 3px solid var(--amber);
}
.navbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  font-size: var(--fs-lg);
  margin-inline-end: auto;
  text-decoration: none;
  letter-spacing: 0.3px;
  padding-inline-end: 12px;
  white-space: nowrap;
}
.navbar .brand img { height: 34px; width: auto; filter: brightness(0) invert(1); }
.nav-item {
  color: #CBD5E1;
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.nav-item i { font-size: 18px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-amber);
}

/* ===== Two selling systems: shop floor + online =====
   Twelve links will not fit on one row, so the bar shows a switcher plus only
   the current system's pages. Online is tinted blue throughout, so a glance at
   the screen tells you which set of data you are about to change. */
.sys-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-pill);
  margin-inline-end: 10px;
}
.sys-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: var(--radius-pill);
  color: #94A3B8;
  text-decoration: none;
  font-weight: 700;
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.sys-tab i { font-size: 15px; }
.sys-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.sys-tab.local.on {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-amber);
}
.sys-tab.online.on {
  background: linear-gradient(135deg, #0EA5E9 0%, #0369A1 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.30);
}

.nav-main, .nav-sys { display: flex; align-items: center; gap: 4px; }
.nav-sys {
  margin-inline-start: auto;
  padding-inline-start: 10px;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.13);
}

/* Inside the online system the active page follows the blue accent. */
.nav-main.online .nav-item.active {
  background: linear-gradient(135deg, #0EA5E9 0%, #0369A1 100%);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.30);
}

/* A thin ribbon under the bar repeats the current system's colour. */
.navbar { border-bottom-color: var(--amber); }
body:has(.nav-main.online) .navbar { border-bottom-color: #0EA5E9; }

/* ===== Print Mode ===== */
@media print {
  /* Chrome / Edge: keep background fills when printing */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  button, .actions, #searchResults, .navbar, .pagination, #toast {
    display: none !important;
  }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  /* Sticky headers would repeat mid-page in print */
  .table thead th { position: static; }
  a { text-decoration: none; color: inherit; }
}

/* ===== Responsive ===== */
/* Narrow desktops (1280 and similar): tighten before anything can clip. */
@media (max-width: 1400px) {
  .navbar { padding: 11px 14px; gap: 4px; }
  .nav-item { padding: 9px 10px; font-size: var(--fs-sm); }
  .sys-tab { padding: 7px 12px; }
  .nav-sys { padding-inline-start: 8px; }
}

@media (max-width: 1024px) {
  .navbar { padding: 10px 12px; }
  .nav-item { padding: 8px 9px; }
  /* Never let the bar clip: it scrolls sideways instead. */
  .navbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .navbar::-webkit-scrollbar { display: none; }
}

@media (max-width: 860px) {
  .container { grid-template-columns: 1fr; padding: 18px; gap: 18px; }
  .card { padding: 20px; }
  .row { flex-direction: column; }
  /* Nav scrolls sideways instead of wrapping into a tall stack */
  .navbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .navbar::-webkit-scrollbar { display: none; }
  .table th, .table td { padding: 11px 12px; }
}

/* Respect a reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
