/* ─── PGF CRM – Main Stylesheet ─────────────────────────────────────────── */

:root {
  --pgf-blue:       #1e5a96;
  --pgf-blue-dark:  #164578;
  --pgf-blue-light: #d0e4f7;
  --pgf-nav-bg:     #1a1a2e;
  --pgf-accent:     #2878c0;
  --pgf-border:     #cfd8e3;
  --pgf-row-hover:  #eef4fb;
  /* Bright cyan-blue used for section headers / active tabs (matches legacy) */
  --pgf-head-bg:    #1ba3c6;
  --pgf-head-text:  #ffffff;
  /* Light grey for table column headers */
  --pgf-thead-bg:   #d8d8d8;
  --pgf-thead-text: #1f2937;
  --pgf-page-bg:    #e6f0f4;
  --pgf-card-bg:    #ffffff;
  --pgf-card-text:  #212529;
  --pgf-search-bg:  #edf3fb;
  --pgf-login-bg:   #d6e8f6;
}

/* ── Dark mode overrides — Bootstrap 5.3 data-bs-theme=dark ─────────────── */
html[data-bs-theme='dark'] {
  --pgf-blue-light: #1c324d;
  --pgf-border:     #3a4350;
  --pgf-row-hover:  #2a323d;
  /* Section-header blue is colourful enough to keep the same in dark mode */
  --pgf-head-bg:    #1ba3c6;
  --pgf-head-text:  #ffffff;
  --pgf-thead-bg:   #2b3340;
  --pgf-thead-text: #cbd5e1;
  --pgf-page-bg:    #15171d;
  --pgf-card-bg:    #1f242d;
  --pgf-card-text:  #d8dee5;
  --pgf-search-bg:  #1d2330;
  --pgf-login-bg:   #1a1e26;
  color-scheme: dark;
}
/* Card-header text stays pure white on the cyan band in dark mode (the
   previous soft blue-grey was hard to read). Table column headers keep
   their muted colour via line 68 / --pgf-thead-text. */
html[data-bs-theme='dark'] .pgf-card-header,
html[data-bs-theme='dark'] .pgf-card-header a {
  color: #ffffff !important;
}
/* Section headings inside form cards ("Client Information", "Billing
   Address", "Contact Details" etc.) use --pgf-blue which is a dark blue
   that's unreadable on the dark page. Force them to white in dark mode. */
html[data-bs-theme='dark'] .pgf-section-heading {
  color: #ffffff !important;
}
html[data-bs-theme='dark'] .text-primary { color: #6ea4d8 !important; }
html[data-bs-theme='dark'] .pgf-finance-link { color: #6ea4d8; }
/* Bootstrap utility classes that hardcode light-mode colours */
html[data-bs-theme='dark'] .bg-light { background-color: var(--pgf-search-bg) !important; color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .table-light { --bs-table-bg: var(--pgf-search-bg); --bs-table-color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .table-active { --bs-table-bg-state: var(--pgf-row-hover); }
html[data-bs-theme='dark'] .text-muted { color: #94a3b8 !important; }
html[data-bs-theme='dark'] .text-dark { color: var(--pgf-card-text) !important; }
/* Card / form / dropdown / modal explicit overrides for any element that
   pgf.css set to a hardcoded light colour */
html[data-bs-theme='dark'] .card { background: var(--pgf-card-bg); color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .form-control,
html[data-bs-theme='dark'] .form-select {
  background-color: var(--pgf-card-bg); color: var(--pgf-card-text); border-color: var(--pgf-border);
}
html[data-bs-theme='dark'] .form-control::placeholder { color: #889aac; }
html[data-bs-theme='dark'] .form-check-input:not(:checked) { background-color: var(--pgf-card-bg); border-color: var(--pgf-border); }
html[data-bs-theme='dark'] .dropdown-menu { background: var(--pgf-card-bg); color: var(--pgf-card-text); border-color: var(--pgf-border); }
html[data-bs-theme='dark'] .dropdown-item { color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .dropdown-item:hover,
html[data-bs-theme='dark'] .dropdown-item:focus { background: var(--pgf-row-hover); color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .modal-content { background: var(--pgf-card-bg); color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .table { color: var(--pgf-card-text); }
html[data-bs-theme='dark'] .pgf-table-head th { background: var(--pgf-thead-bg) !important; color: var(--pgf-thead-text) !important; }
html[data-bs-theme='dark'] .badge.bg-warning { color: #2b1f00 !important; }
html[data-bs-theme='dark'] .alert-success { --bs-alert-bg: #1e3a23; --bs-alert-border-color: #2a5430; --bs-alert-color: #c4e8c8; }
html[data-bs-theme='dark'] .alert-danger  { --bs-alert-bg: #3e1f24; --bs-alert-border-color: #5b2a31; --bs-alert-color: #f1c4c8; }
html[data-bs-theme='dark'] .alert-warning { --bs-alert-bg: #3a3318; --bs-alert-border-color: #574828; --bs-alert-color: #f1e2a3; }
html[data-bs-theme='dark'] .alert-info    { --bs-alert-bg: #1e3037; --bs-alert-border-color: #294453; --bs-alert-color: #b9dbe6; }

/* ── Typography & Reset ──────────────────────────────────────────────────── */
/* Inter — designed for screen readability + tabular numerals so columns of
   IDs / phones / amounts line up vertically. */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--pgf-page-bg);
  color: var(--pgf-card-text);
  margin: 0;
}
/* Numbers in tables are easier to scan when monospaced-aligned */
.table td, .table th { font-variant-numeric: tabular-nums; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.pgf-navbar {
  background-color: var(--pgf-nav-bg) !important;
  padding: 0.25rem 1rem;
  min-height: 48px;
}
.pgf-navbar .navbar-brand { color: #fff !important; }
.pgf-navbar .nav-link     { color: #fff !important; font-size: 0.95rem; font-weight: 600; padding: 0.5rem 0.85rem; }
.pgf-navbar .nav-link:hover,
.pgf-navbar .nav-link.active { color: #fff !important; }
.pgf-navbar .dropdown-menu { font-size: 0.82rem; }
.pgf-navbar .dropdown-item:hover { background: var(--pgf-blue-light); color: var(--pgf-blue-dark); }

/* Legacy-style hover-to-open menus (desktop only — mobile keeps tap-to-open). */
@media (min-width: 992px) {
  .pgf-navbar .nav-item.dropdown:hover > .dropdown-menu { display: block; margin-top: 0; }
  .pgf-navbar .nav-item.dropdown > .dropdown-menu { margin-top: 0; }
}
.navbar-logo-text { font-weight: 600; letter-spacing: 0.02em; font-size: 0.95rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-pgf {
  background-color: var(--pgf-blue);
  border-color: var(--pgf-blue-dark);
  color: #fff;
  font-size: 0.82rem;
}
.btn-pgf:hover { background-color: var(--pgf-blue-dark); color: #fff; }
.btn-pgf-outline {
  border-color: var(--pgf-blue);
  color: var(--pgf-blue);
  font-size: 0.82rem;
}
.btn-pgf-outline:hover { background-color: var(--pgf-blue); color: #fff; }
.btn-xs { padding: 0.1rem 0.4rem; font-size: 0.75rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.pgf-card-header {
  background: var(--pgf-head-bg);
  border-bottom: 1px solid var(--pgf-border);
  color: var(--pgf-head-text);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.45rem 0.75rem;
}
.pgf-card-header a { color: var(--pgf-head-text); }
.card { border-color: var(--pgf-border); }
.card-header { padding: 0.4rem 0.75rem; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.pgf-table-head th {
  background: var(--pgf-thead-bg);
  color: var(--pgf-thead-text);
  border-bottom: 1px solid #b5b5b5;
  font-size: 0.78rem;
  white-space: nowrap;
  padding: 0.3rem 0.5rem;
}

/* Tabs — active tab uses the same bright cyan as section headers */
.nav-tabs .nav-link.active {
  background: var(--pgf-head-bg);
  color: var(--pgf-head-text);
  border-color: var(--pgf-head-bg);
  font-weight: 600;
}
.nav-tabs .nav-link {
  background: var(--pgf-thead-bg);
  color: var(--pgf-thead-text);
  border-color: var(--pgf-border);
  margin-right: 2px;
}
.nav-tabs .nav-link:hover { color: var(--pgf-head-text); background: var(--pgf-head-bg); }
.table td, .table th { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--pgf-row-hover); }
.table-sm td, .table-sm th { padding: 0.25rem 0.4rem; }

/* ── Search Card ─────────────────────────────────────────────────────────── */
.pgf-search-card { background: var(--pgf-search-bg); border-color: var(--pgf-blue-light); }

/* ── Client Header ───────────────────────────────────────────────────────── */
.pgf-client-header {
  background: var(--pgf-blue-light);
  border: 1px solid var(--pgf-border);
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
}

/* ── Main Content Area ───────────────────────────────────────────────────── */
.pgf-main { min-height: calc(100vh - 48px); }

/* ── Section headings within forms ──────────────────────────────────────── */
.pgf-section-heading {
  color: var(--pgf-blue);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--pgf-border);
  padding-bottom: 0.25rem;
  margin-bottom: 0.5rem;
}

/* ── Login page ──────────────────────────────────────────────────────────── */
.pgf-login-body { background: var(--pgf-login-bg); }
.pgf-login-card {
  background: var(--pgf-card-bg);
  border-radius: 0.5rem;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert-success { --bs-alert-bg: #d4edda; --bs-alert-border-color: #c3e6cb; }
.alert-danger  { --bs-alert-bg: #f8d7da; --bs-alert-border-color: #f5c6cb; }
.alert-warning { --bs-alert-bg: #fff3cd; --bs-alert-border-color: #ffeeba; }
.alert-info    { --bs-alert-bg: #d1ecf1; --bs-alert-border-color: #bee5eb; }

/* ── Order Panel ─────────────────────────────────────────────────────────── */
.pgf-order-panel {
  background: var(--pgf-card-bg);
  border-left: 1px solid var(--pgf-border);
  min-height: 300px;
}
.pgf-order-panel .form-label { font-size: 0.78rem; }
.pgf-order-panel .form-control, .pgf-order-panel .form-select { font-size: 0.78rem; }

/* ── Gas bottle table delivery type select ──────────────────────────────── */
#gbTable select.form-select-sm { height: 24px; padding: 1px 4px; font-size: 0.75rem; }

/* ── Stop supply badge in header ─────────────────────────────────────────── */
.pgf-client-header .badge { font-size: 0.7rem; vertical-align: middle; }

/* ── Transaction History link ────────────────────────────────────────────── */
.pgf-finance-link { color: var(--pgf-blue); text-decoration: underline; cursor: pointer; }
.pagination .page-link { color: var(--pgf-blue); }
.pagination .page-item.active .page-link { background: var(--pgf-blue); border-color: var(--pgf-blue-dark); }

/* ── Batch screen ────────────────────────────────────────────────────────── */
.batch-line-row td { padding: 0.15rem 0.3rem; }
.batch-line-row input, .batch-line-row select { font-size: 0.78rem; padding: 0.1rem 0.25rem; }

/* ── PDF print styles ────────────────────────────────────────────────────── */
@media print {
  .pgf-navbar, .pgf-search-card, .btn, nav { display: none !important; }
  .container-fluid { padding: 0 !important; }
  body { font-size: 10pt; }
}

/* ── Corrections from live UI inspection ─────────────────────────── */

/* Search bar - light grey background matches legacy (mode-aware) */
.pgf-search-bar {
  background: var(--pgf-search-bg);
  border-bottom: 2px solid var(--pgf-blue);
}
html[data-bs-theme='dark'] .pgf-search-bar { color: var(--pgf-card-text); }

/* Action Links buttons - exact style from live site */
.btn-pgf-action {
  background: #2878c0;
  color: #fff;
  border: none;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  text-align: center;
  border-radius: 2px;
}
.btn-pgf-action:hover { background: #1e5a96; color: #fff; }

/* Finance panel - transaction history as a link */
.pgf-finance-link { color: #1e5a96; text-decoration: underline; cursor: pointer; }

/* Gas bottle table - $ button green */
.btn-success.btn-xs { background: #28a745; border-color: #1e7e34; }

/* Delivery type dropdown in gas bottle row */
.gb-dtype-select { font-size: 0.72rem; padding: 0.1rem 0.2rem; }

/* Administration base - slightly different bg */
.admin-body { background: var(--pgf-search-bg); }

/* Report viewer iframe style */
.report-frame { background: var(--pgf-card-bg); border: 1px solid var(--pgf-border); }

/* Banking radio buttons inline */
.banking-radios .form-check-inline { margin-right: 1rem; }

/* Journal warning note */
.journal-gst-note { background: #fffbcc; border: 1px solid #e6d800; padding: 4px 8px; font-size: 0.8rem; color: #000; }
html[data-bs-theme='dark'] .journal-gst-note { background: #4a4318; border-color: #6f6228; color: #f7e7a3; }

/* Client header inactive text */
.client-inactive { color: #dc3545; font-weight: bold; }

/* Multiple locations text - red, matches legacy */
.multiple-locations-warning { color: #dc3545; font-weight: bold; }
