/* ============================================================
   جبرة الهندسية — Unified Design System
   Brand palette extracted programmatically from the company logo
   (valve/filter industrial icon): steel-blue body + cream-gold band.
   ============================================================ */
:root {
  --brand: #5D7B89;
  --brand-light: #7C97A3;
  --brand-dark: #46606C;
  --brand-darker: #33454E;
  --brand-nav: #33454E;
  --brand-nav-deep: #212C32;
  --brand-tint: rgba(93, 123, 137, 0.10);
  --brand-tint-md: rgba(93, 123, 137, 0.18);
  --brand-glow: rgba(93, 123, 137, 0.35);

  --accent: #F9EC9F;
  --accent-light: #FFF6C8;
  --accent-dark: #E8D877;

  --danger: #DC2626;   --danger-light: #FEE2E2;
  --warning: #D97706;  --warning-light: #FEF3C7;
  --info: #2563EB;     --info-light: #DBEAFE;
  --success: #16A34A;  --success-light: #DCFCE7;

  --ink: #1A1A1A;
  --bg-page: #F6F8F9;
  --bg-white: #FFFFFF;
  --bg-surface: #FAFBFC;
  --bg-muted: #ECEFF1;

  --text-dark: #1A1A1A;
  --text-body: #33454E;
  --text-muted: #6B7C84;
  --text-on-brand: #FFFFFF;

  --border: #DCE3E6;
  --border-light: #EAEEF0;
  --border-dark: #B9C4C9;

  --shadow-sm: 0 1px 2px rgba(26,26,26,0.06);
  --shadow: 0 2px 8px rgba(26,26,26,0.08);
  --shadow-md: 0 4px 16px rgba(26,26,26,0.10);
  --shadow-lg: 0 12px 32px rgba(26,26,26,0.14);
  --shadow-nav: 0 2px 12px rgba(33,44,50,0.25);

  --r-sm: 6px; --r: 10px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --ease: cubic-bezier(.4,0,.2,1); --ease-fast: cubic-bezier(.4,0,1,1);

  --header-h: 64px; --navbar-h: 52px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  direction: rtl;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }
h1, h2, h3, h4 { color: var(--text-dark); margin: 0 0 .5em; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top navigation ---------- */
.gb-navbar {
  background: var(--brand-nav);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-nav);
  position: sticky; top: 0; z-index: 50;
}
.gb-navbar .container { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.gb-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: #fff; }
.gb-brand img { height: 38px; width: auto; }
.gb-nav-links { display: flex; gap: 22px; align-items: center; }
.gb-nav-links a { color: rgba(255,255,255,.88); font-weight: 500; }
.gb-nav-links a:hover { color: var(--accent); }
.gb-nav-links .btn { margin-inline-start: 6px; }

/* ---------- Nav dropdown menus (المستودع/المبيعات/الحسابات/الإرساليات...) ---------- */
.gb-nav-dropdown { position: relative; }
.gb-nav-dropdown > .gb-nav-dropdown-toggle {
  background: none; border: none; font: inherit; cursor: pointer;
  color: rgba(255,255,255,.88); font-weight: 500; padding: 0; display: flex; align-items: center; gap: 4px;
}
.gb-nav-dropdown > .gb-nav-dropdown-toggle:hover { color: var(--accent); }
.gb-nav-dropdown > .gb-nav-dropdown-toggle::after { content: '▾'; font-size: .7rem; }
.gb-nav-dropdown-menu {
  display: none; position: absolute; top: 100%; inset-inline-start: 0; margin-top: 14px;
  background: #fff; border-radius: var(--r); box-shadow: var(--shadow-md); min-width: 220px;
  padding: 8px 0; z-index: 60;
}
.gb-nav-dropdown.open .gb-nav-dropdown-menu { display: block; }
.gb-nav-dropdown-menu a { display: block; padding: 9px 16px; color: var(--text-dark); font-weight: 500; white-space: nowrap; }
.gb-nav-dropdown-menu a:hover { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; font-size: .95rem; transition: all .15s var(--ease);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); color: var(--ink); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; border-color: var(--border-dark); color: var(--text-body); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 24px;
}
.card + .card { margin-top: 16px; }
.stat-card {
  background: var(--bg-white); border-radius: var(--r-lg); padding: 20px;
  border-inline-start: 4px solid var(--brand); box-shadow: var(--shadow-sm);
}
.stat-card .value { font-size: 1.6rem; font-weight: 800; color: var(--brand-darker); }
.stat-card .label { color: var(--text-muted); font-size: .85rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; color: var(--text-body); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: inherit; font-size: .95rem; background: #fff; color: var(--text-dark);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
/* Checkboxes/radios must stay their native small size — the width:100% rule
   above (meant for text/number/date/select/textarea) was also matching them
   via the bare `input` selector, stretching their clickable area to fill the
   whole row and visually shoving any sibling label text far away from the
   box in flex layouts (e.g. "[  checkbox reserved-100%-width  ] text..."). */
input[type="checkbox"], input[type="radio"] { width: auto; flex: none; accent-color: var(--brand); }
.field { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 180px; }

/* ---------- Tables ---------- */
table.gb-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--r); overflow: hidden; }
table.gb-table thead { background: var(--brand); color: #fff; }
table.gb-table th, table.gb-table td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border-light); }
table.gb-table tbody tr:hover { background: var(--brand-tint); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 700; }
.badge-success { background: var(--success-light); color: #166534; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger { background: var(--danger-light); color: #991B1B; }
.badge-info { background: var(--info-light); color: #1E40AF; }

/* ---------- Search-as-you-type dropdown (reused by POS customer search,
   voucher account search, etc.) ---------- */
.search-dropdown { position: relative; }
.search-dropdown-list { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md); width: 100%; max-height: 240px; overflow-y: auto; margin-top: 4px; display: none; }
.search-dropdown-list.open { display: block; }
.search-dropdown-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border-light); }
.search-dropdown-item:hover { background: var(--brand-tint); }
.selected-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--brand-tint); border-radius: var(--r-pill); padding: 6px 12px; font-size: .85rem; }
.selected-chip button { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 700; }

/* ---------- Alerts / messages ---------- */
.alert { padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: var(--success-light); color: #166534; }
.alert-error { background: var(--danger-light); color: #991B1B; }
.alert-info { background: var(--info-light); color: #1E40AF; }

/* ---------- Footer ---------- */
.gb-footer { background: var(--brand-nav-deep); color: rgba(255,255,255,.75); padding: 32px 0; margin-top: 60px; font-size: .9rem; }
.gb-footer a { color: rgba(255,255,255,.9); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.section { padding: 60px 0; }
.section-title { text-align: center; margin-bottom: 40px; }
.section-title h2 { font-size: 1.8rem; }
.section-title p { color: var(--text-muted); max-width: 640px; margin: 8px auto 0; }

.gb-nav-toggle {
  display: none; background: none; border: none; color: #fff; font-size: 1.5rem;
  line-height: 1; cursor: pointer; padding: 4px 6px;
}

@media (max-width: 768px) {
  .gb-nav-toggle { display: block; }
  .gb-nav-links {
    display: none; position: absolute; inset-inline: 0; top: 100%;
    background: var(--brand-nav); flex-direction: column; align-items: stretch;
    gap: 4px; padding: 12px 20px 18px; box-shadow: var(--shadow-nav);
    max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  }
  .gb-nav-links.open { display: flex; }
  .gb-nav-links .btn { margin-inline-start: 0; align-self: flex-start; }
  .gb-nav-dropdown { width: 100%; }
  .gb-nav-dropdown > .gb-nav-dropdown-toggle { width: 100%; padding: 10px 4px; justify-content: space-between; }
  .gb-nav-dropdown-menu {
    display: none; position: static; margin-top: 0; box-shadow: none; background: rgba(255,255,255,.06);
    border-radius: var(--r-sm); padding: 4px 0; min-width: 0;
  }
  .gb-nav-dropdown.open .gb-nav-dropdown-menu { display: block; }
  .gb-nav-dropdown-menu a { color: rgba(255,255,255,.88); padding: 9px 16px; }
  .gb-nav-dropdown-menu a:hover { background: rgba(255,255,255,.08); color: var(--accent); }
  .section { padding: 36px 0; }
}

/* ---------- Reports / print ---------- */
.rpt-header-img { width: 100%; height: auto; display: block; margin: 0 0 20px; border-radius: var(--r); }
.print-card { box-shadow: none; border: none; }

/* Authoritative print rule — hides the navbar/footer/any .no-print element on
   EVERY page whenever printed (Ctrl+P or window.print()), regardless of
   whether a view remembered to pass print_mode. This is what actually runs
   at print time; the print_mode-driven inline <style> some views also render
   is redundant with this but harmless. */
@media print {
  .gb-navbar, .gb-footer, .no-print { display: none !important; }
  body { background: #fff; }
  .container { max-width: 100%; padding: 0; }
}

/* ---------- htmx loading indicator (standard htmx convention) ---------- */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
