/* Oregano ERP design system — Bootstrap 5 theme layer.
   Tokens lifted verbatim from the Figma file (Oregano ERP - Formis). */

:root {
  --oregano-maroon: rgb(118, 6, 25);
  --oregano-maroon-dark: rgb(94, 5, 20);
  --oregano-red: rgb(169, 0, 0);
  --oregano-olive: rgb(134, 137, 32);
  --oregano-olive-soft: rgba(134, 137, 32, 0.4);
  --oregano-olive-ink: rgb(46, 66, 1);
  --oregano-cream: rgb(250, 248, 241);
  --oregano-surface: rgb(251, 253, 255);
  --oregano-ink: rgb(0, 0, 0);
  --oregano-ink-80: rgba(0, 0, 0, 0.8);
  --oregano-ink-60: rgba(0, 0, 0, 0.6);
  --oregano-border: rgba(0, 0, 0, 0.2);
  --oregano-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  --oregano-sidebar-w: 280px;
  --oregano-topbar-h: 80px;

  --bs-primary: var(--oregano-maroon);
  --bs-primary-rgb: 118, 6, 25;
  --bs-body-font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--oregano-ink);
  --bs-link-color: var(--oregano-maroon);
  --bs-link-hover-color: var(--oregano-maroon-dark);
}

body {
  background-color: var(--oregano-cream);
  color: var(--oregano-ink);
}

a { color: var(--bs-link-color); }
a:hover { color: var(--bs-link-hover-color); }

.font-display {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif;
  letter-spacing: -0.3px;
}

.font-ui {
  font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---- App shell: topbar + sidebar + content ---- */

.app-topbar {
  height: var(--oregano-topbar-h);
  background: #fff;
  box-shadow: var(--oregano-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-topbar__brand { display: flex; flex-direction: column; align-items: center; gap: 0; text-decoration: none; justify-content: center; }
.app-topbar__brand img { height: 65px; width: auto; margin-bottom: 0; }
.app-topbar__tagline {
  font-family: "Raleway", sans-serif;
  font-weight: 400;
  font-size: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--oregano-ink-60);
  margin: -2px 0 0 0;
  line-height: 1;
}

.app-topbar__user { display: flex; align-items: center; gap: 14px; }
.app-topbar__avatar {
  width: 37px;
  height: 37px;
  border-radius: 50%;
  background: var(--oregano-maroon);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Raleway", sans-serif;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.app-topbar__name { font-size: 14px; line-height: 1.2; }
.app-topbar__role { font-size: 12px; color: var(--oregano-ink-60); line-height: 1.2; }

.app-body { display: flex; align-items: flex-start; min-height: calc(100vh - var(--oregano-topbar-h)); }

.app-sidebar {
  width: var(--oregano-sidebar-w);
  flex-shrink: 0;
  background: var(--oregano-maroon);
  box-shadow: 4px 0 4px rgba(0, 0, 0, 0.25);
  height: calc(100vh - var(--oregano-topbar-h));
  overflow-y: auto;
  padding: 24px;
  position: sticky;
  top: var(--oregano-topbar-h);
}

.app-sidebar::-webkit-scrollbar {
  width: 4px;
}

.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.app-sidebar__group + .app-sidebar__group { margin-top: 28px; }
.app-sidebar__group-label {
  font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 10px;
  padding: 0 12px;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif;
  letter-spacing: 0.5px;
  text-decoration: none;
  margin-bottom: 4px;
  transition: background-color 0.15s ease;
}
.app-sidebar__link i {
  font-size: 18px;
  width: 24px;
  text-align: center;
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
}
.app-sidebar__link:hover { background: #5F4619; color: #fff; }
.app-sidebar__link:hover i { color: #fff; }
.app-sidebar__link.is-active { background: #5F4619; color: #fff; font-weight: 600; border-left: 4px solid #868920; }
.app-sidebar__link.is-active i { color: #fff; }

.app-crumb {
  background: var(--oregano-maroon);
  box-shadow: var(--oregano-shadow);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 40px;
  color: rgba(255, 255, 255, 0.9);
  font-family: "Raleway", sans-serif;
  font-size: 12px;
  text-transform: capitalize;
  gap: 8px;
}
.app-crumb a { color: rgba(255, 255, 255, 0.8); text-decoration: none; }
.app-crumb a:hover { color: #fff; }
.app-crumb__current { color: #fff; font-weight: 700; }

.app-main { flex: 1; min-width: 0; background: var(--oregano-cream); min-height: calc(100vh - var(--oregano-topbar-h)); display: flex; flex-direction: column; }
.app-content {
  background: var(--oregano-surface);
  padding: 48px 40px;
  margin: 0;
  flex: 1;
  min-height: 0;
}

/* ---- Page header ---- */

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.page-header__title { font-size: 32px; margin: 0; line-height: 1.1; }
.page-header__subtitle { font-size: 13px; color: var(--oregano-ink-60); margin: 4px 0 0; }

/* ---- Cards ---- */

.card-oregano {
  background: #fff;
  box-shadow: inset 0 0 0 0.2px var(--oregano-border), var(--oregano-shadow);
  border: none;
  border-radius: 0;
  padding: 24px;
}
.card-oregano__title { font-size: 20px; font-weight: 700; margin: 0 0 16px; }

/* ---- Tables ---- */

.table > thead {
  background-color: #868920 !important;
  color: #fff !important;
}
.table > thead > tr > th {
  background-color: #868920 !important;
  color: #fff !important;
  border: none !important;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15) !important;
  font-weight: 600;
  font-size: 15px;
  text-transform: capitalize;
  vertical-align: middle;
  padding: 18px 20px;
}
.table > tbody > tr > td {
  padding: 14px 20px;
  vertical-align: middle;
  font-size: 14px;
  border-bottom: 1px solid var(--oregano-border);
}
.table > tbody > tr:last-child > td { border-bottom: none; }
.table { box-shadow: var(--oregano-shadow); }

/* Vertical scroll container for long tables (kitchen sheet stock lines):
   the table scrolls within its card instead of stretching the page, and
   the header row stays pinned while scrolling. border-collapse must be
   separate for the sticky th's border-bottom to scroll with the header
   (collapsed borders don't stick); border-spacing 0 keeps the look
   identical. */
.table-scroll-y {
  max-height: 30rem;
  overflow-y: auto;
}
.table-scroll-y .table { border-collapse: separate; border-spacing: 0; }
.table-scroll-y .table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ---- Badges ---- */

.badge-status-active {
  background: var(--oregano-olive-soft);
  color: var(--oregano-olive-ink);
  font-weight: 400;
  font-size: 13px;
  text-transform: capitalize;
  border-radius: 2px;
  padding: 5px 12px;
}
.badge-status-inactive {
  background: rgba(0, 0, 0, 0.08);
  color: var(--oregano-ink-60);
  font-weight: 400;
  font-size: 13px;
  text-transform: capitalize;
  border-radius: 2px;
  padding: 5px 12px;
}

/* ---- Buttons ---- */

.btn-primary { background-color: var(--oregano-maroon); border-color: var(--oregano-maroon); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--oregano-maroon-dark) !important;
  border-color: var(--oregano-maroon-dark) !important;
}
.btn-outline-primary { background-color: #877555; border: none; color: #fff; border-radius: 0 !important; }
.btn-edit::before {
  content: "\F4CB";
  font-family: "bootstrap-icons";
  margin-right: 6px;
  font-size: 0.9em;
  display: inline-block;
  vertical-align: -0.1em;
}
[id*="-history"]::before { content: none; }
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
  background-color: #6d5e44 !important;
  border: none !important;
  color: #fff !important;
}
.btn-outline-secondary { background: transparent; border: 1px solid #877555; color: #877555; border-radius: 0 !important; }
.btn-outline-secondary:hover, .btn-outline-secondary:focus, .btn-outline-secondary:active {
  background-color: #6d5e44 !important;
  border-color: #6d5e44 !important;
  color: #fff !important;
}
.btn-secondary { background: transparent; border: 1px solid #877555; color: #877555; border-radius: 0 !important; }
.btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active {
  background-color: #6d5e44 !important;
  border-color: #6d5e44 !important;
  color: #fff !important;
}
.btn { border-radius: 4px; font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif !important; letter-spacing: 1px; }

/* ---- Brown Add Button ---- */

.btn-add { background-color: #877555; border-color: #877555; color: #fff; border-radius: 0 !important; }
.btn-add:hover, .btn-add:focus, .btn-add:active {
  background-color: #6d5e44 !important;
  border-color: #6d5e44 !important;
  color: #fff !important;
}
.btn-add i {
  font-size: 1.3em;
  vertical-align: -0.15em;
  display: inline-block;
  line-height: 1;
}

/* ---- Navbar Logout Button ---- */

#nav-logout-btn { border-radius: 4px !important; }
.page-header .btn {
  align-items: center;
  display: inline-flex;
  height: 38px;
}

/* ---- Stat / placeholder chart cards (Home dashboard) ---- */

.stat-card {
  background: #fff;
  box-shadow: inset 0 0 0 0.2px var(--oregano-border), var(--oregano-shadow);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.stat-card__label { font-size: 12px; color: var(--oregano-ink-60); }
.stat-card__value { font-size: 24px; font-weight: 700; font-family: "Forum", serif; }
.stat-card__delta { font-size: 12px; }
.stat-card__delta.is-up { color: rgb(0, 99, 38); }
.stat-card__delta.is-down { color: rgb(116, 0, 0); }

.chart-placeholder {
  height: 177px;
  border: 1px dashed var(--oregano-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--oregano-ink-60);
  font-size: 12px;
  text-align: center;
  background: repeating-linear-gradient(135deg, rgba(0,0,0,0.03) 0 10px, transparent 10px 20px);
}

/* ---- Detail page field rows (Outlet Details) ---- */

.field-row { margin-bottom: 20px; }
.field-row__label {
  font-size: 12px;
  color: var(--oregano-ink-60);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 4px;
}
.field-row__value { font-size: 16px; margin: 0; }
.field-row__value.is-placeholder { color: var(--oregano-ink-60); font-style: italic; font-size: 14px; }

/* ---- Auth screen ---- */

.auth-shell {
  min-height: calc(100vh - var(--oregano-topbar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--oregano-cream);
  padding: 40px 16px;
  gap: 24px;
}
.auth-card {
  background: #fff;
  box-shadow: inset 0 0 0 0.2px var(--oregano-border), var(--oregano-shadow);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

/* ---- Search inputs ---- */

.app-search {
  position: relative;
  width: 300px;
}
.app-search input {
  padding-left: 42px;
  width: 100%;
}
.app-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--oregano-ink-60);
  font-size: 16px;
  pointer-events: none;
}

/* ---- Form inputs Forum font ---- */

.form-control, .form-select {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif !important;
  border-radius: 0 !important;
}

.form-control::placeholder {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif;
  opacity: 1;
  color: var(--oregano-ink);
}

/* Form input focus with green highlight */
.form-control:focus {
  border-color: #868920 !important;
  box-shadow: 0 0 0 0.25rem rgba(134, 137, 32, 0.25) !important;
}

.form-select {
  border-radius: 0 !important;
}

.form-select:focus {
  border-color: #868920 !important;
  box-shadow: 0 0 0 0.25rem rgba(134, 137, 32, 0.25) !important;
}

.form-check-input {
  border-radius: 0 !important;
}

.form-check-input:focus {
  border-color: #868920 !important;
  box-shadow: 0 0 0 0.25rem rgba(134, 137, 32, 0.25) !important;
}

/* Checkbox checked state with green tick */
.form-check-input:checked {
  background-color: #868920 !important;
  border-color: #868920 !important;
}

/* ---- Tom Select (searchable dropdowns) — match the app's input look ----
   The widget's control is .ts-control, not .form-select, so the overrides
   above don't reach it: square corners, Forum font, olive hover/focus. */

.ts-wrapper .ts-control {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif !important;
  border-radius: 0 !important;
}

/* Placeholder in the search input: same look as .form-control::placeholder. */
.ts-wrapper .ts-control > input::placeholder {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif;
  opacity: 1;
  color: var(--oregano-ink);
}

/* Hover: the same olive border as .form-select:focus above (no glow until
   the widget actually has focus). */
.ts-wrapper:hover .ts-control,
.ts-wrapper.focus .ts-control {
  border-color: #868920 !important;
}

.ts-wrapper.focus .ts-control {
  box-shadow: 0 0 0 0.25rem rgba(134, 137, 32, 0.25) !important;
}

.ts-dropdown {
  font-family: "Forum", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif !important;
  border-radius: 0 !important;
}

/* Hovered/active option: the app's olive-soft highlight (same pairing as
   the olive badges) instead of the theme's flat gray. */
.ts-dropdown .active {
  background-color: var(--oregano-olive-soft) !important;
  color: var(--oregano-olive-ink) !important;
}

/* The wizard tables are .table-responsive (overflow: auto), which clips the
   dropdown and hangs scrollbars on the table while it's open — let it
   escape on desktop; phones keep the table's own horizontal scroll. */
@media (min-width: 768px) {
  #line-formset-container .table-responsive {
    overflow: visible;
  }
}

/* Open the item dropdown ABOVE the control (the theme's default is below,
   where it covers the rows underneath). Flipped edge: restore the top
   border the theme removes for below-placement, and mirror the shadow. */
.line-form-row .ts-dropdown {
  top: auto !important;
  bottom: 100% !important;
  margin: 0 0 0.25rem !important;
  border: 1px solid var(--bs-border-color) !important;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1) !important;
}


/* ---- HTMX loading indicators ---- */

.htmx-indicator {
  display: none;
  font-size: 14px;
  color: var(--oregano-ink-60);
  margin-left: 8px;
}
.htmx-request .htmx-indicator {
  display: inline;
}
.htmx-request .htmx-requesting {
  opacity: 0.6;
  pointer-events: none;
}

/* Circular loading spinner inside search box */
.loading-spinner {
  display: none;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--oregano-ink-60);
}

/* Responsive for mobile */
@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-content { padding: 32px 20px; }
}

/* ---- Purchase invoice wizard ---- */

.page-title { font-size: 28px; }

/* Document context strip — reusable: horizontal label/value pairs under
   the page title. */
.doc-context {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

/* Colored section bars  */
.section-bar {
  font-size: 1.4rem;
  letter-spacing: 0.05em;
}
.section-bar--olive { background-color: var(--oregano-olive); }
.section-bar--red { background-color: #a90000; }

.section-title { font-size: 24px; }

/* Field label + field box — the shared label-over-value pattern: a
   font-display label above either a bordered value box (.field-box) or a
   form input. Shared by the LPO / petty-cash / invoice wizards' header
   recaps, the invoice wizard's mismatch amount rows, and its form field
   labels (replaces the inline font-size/border-color styles previously
   copy-pasted per template). */
.field-label {
  color: #212529;
  margin-bottom: 0.25rem;
  font-size: 1.2rem;
}
.field-box {
  border: 1px solid var(--oregano-border);
  padding: 0.5rem;
  color: #212529;
  white-space: pre-wrap;
  /* anywhere (not break-word) also shrinks min-content sizing, so a long
     unbroken value (LPO number, TRN) wraps instead of forcing its column
     wider than its grid share. */
  overflow-wrap: anywhere;
}

/* Any input contradicting its source — invoice price vs PO price,
   received qty vs pending quantity — wears the mismatch red border.
   !important mirrors .form-control:focus's own olive glow above; the
   focus ring is the same red at 25%. */
.mismatch-input,
.mismatch-input:focus {
  border-color: var(--oregano-red);
}
.mismatch-input:focus {
  border-color: var(--oregano-red) !important;
  box-shadow: 0 0 0 0.2rem rgba(169, 0, 0, 0.25) !important;
}

/* Optional stronger variant: paint the whole field, not just the border
   (step 2's mismatching price cell). */
.mismatch-input-filled,
.mismatch-input-filled:focus {
  background-color: var(--oregano-red);
  color: #fff;
}

/* Wizard decision buttons: flat squares (no border radius), each with
   its own hover shade. Post's hover = --oregano-olive-ink token. */
.btn-invoice-post,
.btn-invoice-hold,
.btn-invoice-reject {
  color: #fff;
  border-radius: 0;
}
.btn-invoice-post {
  background-color: #6c6d43;
  border-color: #6c6d43;
}
.btn-invoice-post:hover,
.btn-invoice-post:focus {
  background-color: var(--oregano-olive-ink);
  border-color: var(--oregano-olive-ink);
  color: #fff;
}
.btn-invoice-hold {
  background-color: #877555;
  border-color: #877555;
}
.btn-invoice-hold:hover,
.btn-invoice-hold:focus {
  background-color: #5c5240;
  border-color: #5c5240;
  color: #fff;
}
.btn-invoice-reject {
  background-color: #7a3636;
  border-color: #7a3636;
}
.btn-invoice-reject:hover,
.btn-invoice-reject:focus {
  background-color: #a90000;
  border-color: #a90000;
  color: #fff;
}
.btn-invoice-post:disabled,
.btn-invoice-hold:disabled,
.btn-invoice-reject:disabled {
  /* Disabled = clearly present but greyed out: solid neutral grey, no
     Bootstrap opacity fade (which read as "button missing"). */
  background-color: #999999;
  border-color: #999999;
  color: #fff;
  opacity: 1;
  cursor: not-allowed;
}

/* Invoice wizard table column widths. */
#invoice-line-table th:nth-child(1) { width: 28%; }
#invoice-line-table th:nth-child(2) { width: 12%; }
#invoice-line-table th:nth-child(3) { width: 12%; }
#invoice-line-table th:nth-child(4) { width: 14%; }
#invoice-line-table th:nth-child(5) { width: 12%; }
#invoice-line-table th:nth-child(6) { width: 14%; }

#invoice-review-table th:nth-child(1) { width: 18%; }
#invoice-review-table th:nth-child(2) { width: 9%; }
#invoice-review-table th:nth-child(3) { width: 9%; }
#invoice-review-table th:nth-child(4) { width: 9%; }
#invoice-review-table th:nth-child(5) { width: 8%; }
#invoice-review-table th:nth-child(6) { width: 8%; }
#invoice-review-table th:nth-child(7) { width: 9%; }
#invoice-review-table th:nth-child(8) { width: 13%; }
#invoice-review-table th:nth-child(9) { width: 11%; }

/* LPO + petty cash wizard table column widths (the two wizards share the
   #line-items-table id, so scope by their form ids). */
#lpo-create-form #line-items-table th:nth-child(1) { width: 35%; }
#lpo-create-form #line-items-table th:nth-child(2) { width: 12%; }
#lpo-create-form #line-items-table th:nth-child(3) { width: 12%; }
#lpo-create-form #line-items-table th:nth-child(4) { width: 12%; }
#lpo-create-form #line-items-table th:nth-child(5) { width: 17%; }

#petty-cash-form #line-items-table th:nth-child(1) { width: 32%; }
#petty-cash-form #line-items-table th:nth-child(2) { width: 12%; }
#petty-cash-form #line-items-table th:nth-child(3) { width: 13%; }
#petty-cash-form #line-items-table th:nth-child(4) { width: 20%; }
#petty-cash-form #line-items-table th:nth-child(5) { width: 23%; }

/* Wizard totals tables: label/value halves, rule above the total row. */
#lpo-totals-table td,
#petty-cash-totals-table td { width: 50%; }
#lpo-totals-table tr.fw-bold td,
#petty-cash-totals-table tr.fw-bold td { border-top: 1px solid #dee2e6; }

/* Calendar filtering styles — the LPO list's date/month filters are native
   date inputs, which ignore the placeholder attribute: the hint ("Month",
   "From date", "To date") is overlaid via data-hint while the field is
   empty and hides on focus or once a value is picked. The right inset
   leaves the native calendar-picker icon visible. The .has-value toggling
   script lives in the lpo_list template. */
.date-hint { position: relative; }
.date-hint:not(:focus):not(.has-value)::before {
  content: attr(data-hint);
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 2.25rem;
  padding: 0.375rem 0 0 0.75rem;
  color: #212529;
  background: #fff;
  pointer-events: none;
}
