/* public_html/assets/css/base.css
   Nama Asset Verification -- shared design system.
   Design tokens live in :root as CSS variables so every future page
   reuses the same palette/spacing/type scale instead of hardcoding
   values inline. Primary color (#11464e) is sampled directly from the
   official Nama Water Services logo -- see assets/source/nama-logo.png. */

:root {
  /* Palette -- authentic Nama teal, sampled from the official logo */
  --color-primary: #11464e;
  --color-primary-dark: #0a2e33;
  --color-primary-light: #e6edec;
  --color-accent: #1c6f66;

  --color-navy: #1f2937;
  --color-text: #1f2937;
  /* Darkened from #5b6572 -- a contrast pass: muted text (tabs, labels,
     hints) still reads as clearly secondary to --color-text, but was
     previously pale enough to feel washed out on the lighter --color-bg
     below. */
  --color-text-muted: #4b5563;
  /* Both border tiers darkened a step together so the two-tier
     relationship (border-strong is "more visible than default") still
     holds -- cards, inputs, dropdowns, and table cells all read with a
     clearer edge against the slightly stronger page background. */
  --color-border: #cfd9d7;
  --color-border-strong: #b7c8c3;
  /* UI polish pass (desktop/tablet, high-contrast): a third, deliberately
     dark tier for the handful of places that need to read as a strong,
     deliberate line rather than a soft edge -- table header/card bottom
     rules, active tab underlines, the Manage Facilities-style modal's
     internal group dividers. Never used for a plain card/input border
     (that stays -strong), only for a rule meant to be NOTICED. */
  --color-border-emphasis: #9db3ac;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f7f7;
  /* A third surface tier -- a touch deeper than -muted, for a
     "highlighted/active card" or a modal's sunken search/list well (Manage
     Facilities' facility-picker), so that layer reads as visually distinct
     from a plain muted card body rather than reusing the same flat tone
     for two different jobs. */
  --color-surface-sunken: #eef2f1;
  /* Slightly stronger cool gray than the previous #f2f5f4 -- gives white
     cards real separation from the page instead of nearly blending into
     it, without turning the page dark or colorful. */
  --color-bg: #e9eeed;
  /* Dedicated table-header tone, a step deeper than --color-primary-light
     (#e6edec) so header rows read as clearly structural even against a
     white table body, without repurposing the shared primary-light token
     (used elsewhere for active nav / badges / pills). */
  --color-table-header-bg: #dbe6e3;

  --color-success: #146c42;
  --color-success-bg: #dcf3e7;
  --color-success-border: #a6dcbf;
  --color-danger: #a3251e;
  --color-danger-bg: #fbeceb;
  --color-danger-border: #eab5b1;
  --color-warning: #8a5c00;
  --color-warning-bg: #faecc8;
  --color-warning-border: #e9cd8c;
  --color-info: #1c5d8a;
  --color-info-bg: #e8f2fa;
  --color-info-border: #b7d7ea;
  /* Neutral badge/pill tone -- deliberately warmer and a step darker than
     plain --color-surface-muted (UI polish pass: "Pending" badges were
     reading as flat, washed-out gray). A soft warm stone rather than cool
     gray, paired with --color-text (not -muted) for the label so a
     Pending badge reads as high-contrast and intentional, never faded. */
  --color-neutral-bg: #e7e2d9;
  --color-neutral-border: #d3ccbd;
  --color-neutral-text: #57503f;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 1.75rem;
  --line-height-base: 1.5;

  /* Borders / radius / shadow */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 22, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 22, 0.08);
  --shadow-card: 0 24px 60px rgba(10, 46, 51, 0.12);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 0px;
  --header-height: 72px;
  --content-max-width: 1800px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #e7ecea;
    --color-text-muted: #a3adaa;
    --color-border: #2b3634;
    --color-surface: #16201e;
    --color-surface-muted: #1c2725;
    --color-bg: #101816;
    --color-primary-light: #16302c;
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Defensive: a translateX()'d position:fixed element (the off-canvas
     sidebar drawer) establishes its own containing block and can still
     contribute to the document's scrollable width in some engines even
     while visually off-screen, which would otherwise open up a phantom
     horizontal scroll on mobile. Clamping it here at the root is the
     standard, safe fix regardless of which element ever causes it. */
  overflow-x: hidden;
}

/* Applied to <html> by app.js's modal system while any modal is open --
   the page behind a modal (the Add Asset modal especially, tall enough
   to need its own internal scroll) must stay put rather than scrolling
   along with an attempt to scroll the modal body. */
html.body-scroll-locked {
  overflow-y: hidden;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  color: var(--color-text);
}

p { margin: 0 0 var(--space-3); }

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul, ol { margin: 0; padding: 0; list-style: none; }

/* Focus visibility -- never suppressed, only restyled */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Layout utility */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.text-muted { color: var(--color-text-muted); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons -- UI polish pass: every variant gets a real hover elevation
   (a soft shadow lift, not just a color swap), a visible :active "pressed"
   state, and an explicit :focus-visible ring so keyboard focus is never
   left to the browser's inconsistent default outline. Disabled buttons
   also lose the hover/active transforms entirely (see :disabled guards
   already on each transition-affecting rule below). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(10, 46, 51, 0.15);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); text-decoration: none; box-shadow: 0 4px 10px rgba(10, 46, 51, 0.25); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-emphasis);
  font-weight: 700;
}
.btn-secondary:hover:not(:disabled) { background: var(--color-primary-light); border-color: var(--color-primary); text-decoration: none; }

.btn-link {
  background: transparent;
  color: var(--color-primary);
  padding: 4px 0;
}
.btn-link:hover:not(:disabled) { text-decoration: underline; }
.btn-link:active:not(:disabled) { transform: none; }

/* Stronger than plain .btn-secondary (teal border, but --color-text
   body-gray text) -- teal border AND teal text together, for an action
   that's clearly available and worth noticing but shouldn't compete with
   the dialog's actual primary button (e.g. Facility Info's "Edit
   Information" next to a plain "Close"). */
.btn-primary-outline {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
  border-width: 1.5px;
  font-weight: 700;
}
.btn-primary-outline:hover:not(:disabled) { background: var(--color-primary-light); box-shadow: 0 2px 6px rgba(10, 46, 51, 0.12); }
.btn-primary-outline:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: var(--font-size-xs); }
.btn-pill { border-radius: var(--radius-pill); }
.btn-danger { background: var(--color-danger); color: #fff; box-shadow: 0 1px 2px rgba(163, 37, 30, 0.2); }
.btn-danger:hover:not(:disabled) { background: #841e18; box-shadow: 0 4px 10px rgba(163, 37, 30, 0.3); }

/* Visually destructive but restrained -- Delete Asset (Edit Asset modal
   footer): a red outline, not a solid red fill, so it reads as
   "available but deliberate" next to the calmer Cancel/Save Changes
   pair rather than dominating the footer the way a solid .btn-danger
   would. The actual confirmation (asset_delete_modal.php) still uses
   solid .btn-danger for its own "Delete Asset" submit -- that's the
   point of no return, this is just the entry point to it. */
.btn-danger-outline {
  background: var(--color-surface);
  color: var(--color-danger);
  border-color: var(--color-danger);
  font-weight: 700;
}
.btn-danger-outline:hover:not(:disabled) { background: var(--color-danger-bg); box-shadow: 0 2px 6px rgba(163, 37, 30, 0.15); }

/* Export module -- "Download Incomplete Export" (item 13) deliberately
   uses a THIRD, amber tone rather than reusing .btn-primary (which would
   look identical to a normal, fully-ready download) or .btn-danger (too
   alarming for "still allowed, just not final yet"). .btn-lg is a
   one-off larger size for that same single most-important action on the
   Review & Download step. */
.btn-warning {
  background: var(--color-warning);
  color: #fff;
  box-shadow: 0 1px 2px rgba(138, 92, 0, 0.2);
}
.btn-warning:hover:not(:disabled) { background: #6e4900; box-shadow: 0 4px 10px rgba(138, 92, 0, 0.3); }
.btn-lg { padding: 14px 28px; font-size: var(--font-size-base); }

/* Forms */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-control {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: var(--font-size-base);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface-muted);
  /* border-strong (not the default --color-border) -- a contrast-pass
     correction: every text input, select, and textarea in the app shares
     this one rule, so a single change here is what makes "form input
     borders" and "dropdown borders" (selects use .form-control too) read
     clearly everywhere at once, without hunting per-page CSS. */
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.form-control:hover:not(:focus):not(:disabled) {
  border-color: var(--color-border-emphasis);
}
.form-control:focus {
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(28, 111, 102, 0.22);
  outline: none;
}
.form-control[aria-invalid="true"] {
  border-color: var(--color-danger);
}
.form-control:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
/* A <select> uses .form-control too (no separate class) -- an explicit
   pointer cursor and a slightly stronger chevron affordance make it read
   as a dropdown control, not indistinguishable from a plain text input. */
select.form-control {
  cursor: pointer;
}

.form-control-sm {
  height: 36px;
  padding: 0 10px;
  font-size: var(--font-size-sm);
}

.form-hint {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.form-error {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-danger);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.password-field-wrap {
  position: relative;
}
.password-field-wrap .form-control {
  padding-right: 64px;
}
.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px 10px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
}
.password-toggle-btn:hover { text-decoration: underline; }

/* Cards -- UI polish pass: a visibly stronger border + a real (if soft)
   shadow so a card reads as a distinct, raised surface against the page
   background rather than a barely-there rectangle. A subtle hover lift is
   opt-in via .card--interactive (cards that are themselves a click target,
   e.g. the Governorate/Facility selection grid's .location-card, which
   layers its own richer treatment on top of this base). */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.card-body { padding: var(--space-5); }

.card-header {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
}

/* Badges -- UI polish pass: every variant now carries its own tinted
   BORDER (not just a tinted background), a touch more padding, and a
   slightly heavier weight, so a badge reads as a deliberately designed
   status pill at a glance instead of a flat, low-contrast tint. Pending-
   style states use .badge-neutral's new warm, higher-contrast treatment
   (--color-neutral-*, base.css :root) rather than a washed-out cool gray. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: rgba(17, 70, 78, 0.18); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }
.badge-neutral { background: var(--color-neutral-bg); color: var(--color-neutral-text); border-color: var(--color-neutral-border); }

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
}
/* An alert dynamically toggled via the `hidden` attribute (e.g. the
   Print QR Labels dialog's "all selected already printed" notice) would
   otherwise stay visibly flexed despite being "hidden" -- [hidden]'s
   equal-specificity fight against this rule's own `display: flex` is won
   by the author rule, not the browser's [hidden]{display:none} UA rule.
   Same recurring fix already applied to .modal-backdrop/.modal-footer/
   .location-card elsewhere in this app. */
.alert[hidden] {
  display: none;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(26, 127, 78, 0.2); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(179, 38, 30, 0.2); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(138, 92, 0, 0.2); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: rgba(28, 93, 138, 0.2); }

/* Tables -- .table-wrap is the ONE reusable horizontal-scroll container
   every data table in the app shares (Settings > Users, Audit Log, and
   any future one): the table itself keeps a comfortable min-width and
   never wraps its cell text, so on a narrow viewport the *container*
   scrolls sideways instead of the page, and instead of cramming/
   wrapping column content illegibly. */
.table-wrap {
  overflow-x: auto;
  width: 100%;
  /* Nama-teal scrollbar, restrained: thin, rounded, teal thumb on a
     pale track. scrollbar-color is the Firefox/standard equivalent of
     the ::-webkit-scrollbar-* rules below. */
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) var(--color-surface-muted);
}
.table-wrap::-webkit-scrollbar {
  height: 8px;
}
.table-wrap::-webkit-scrollbar-track {
  background: var(--color-surface-muted);
  border-radius: var(--radius-pill);
}
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-dark);
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.table th, .table td {
  padding: 13px var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table th {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-primary-dark);
  background: var(--color-table-header-bg);
  /* A crisper, darker rule under the header row than the plain --color-border
     every other cell uses -- the header needs to read as clearly
     structural, not just another striped row. */
  border-bottom: 2px solid var(--color-border-emphasis);
}
/* Subtle zebra striping -- declared BEFORE :hover below so hover (equal
   selector specificity) always wins the cascade on an even row. Faint
   enough to aid scanning across a wide table without competing with the
   semantic status badges inside each row. */
.table tbody tr:nth-child(even) {
  background: rgba(17, 70, 78, 0.025);
}
.table tbody tr:hover {
  background: rgba(17, 70, 78, 0.07);
}

/* Empty states -- UI polish pass: a touch more breathing room and a
   clearer title/subtext hierarchy so an empty page reads as a deliberate,
   polished placeholder rather than a page that simply has nothing on it
   yet. */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--color-text-muted);
}
.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.empty-state p {
  max-width: 440px;
  margin-inline: auto;
}

/* Stat / metric cards (Dashboard) -- UI polish pass: a real top accent
   bar + stronger border/shadow so a lone row of these doesn't read as a
   half-finished page, plus two semantic modifiers (--accent for an
   "in-progress/open" figure, --success for a "done" one) so the numbers
   themselves carry meaning at a glance without needing icons or copy. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
}
.stat-card--accent { border-top-color: var(--color-info); }
.stat-card--success { border-top-color: var(--color-success); }
.stat-card--warning { border-top-color: var(--color-warning); }
.stat-card--danger { border-top-color: var(--color-danger); }
.stat-card-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-3);
}
.stat-card-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.1;
}
.stat-card-note {
  margin-top: var(--space-2);
  margin-bottom: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Brand mark placeholder (used only if the logo SVG asset is ever missing) */
.brand-logo--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  flex-shrink: 0;
}
.brand-logo-mark {
  color: #fff;
  font-weight: 700;
  font-size: var(--font-size-lg);
  line-height: 1;
}
