/* Snac Fresh StockRoute theme (shared by the staff console, Supplier Portal and Customer Portal).
   The admin theme starter: Bootstrap 5.3 + Bootstrap Icons, a dark sidebar, a white top bar, soft cards,
   uppercase table headings, KPI cards, toasts and a gradient sign-in page. Then a compatibility layer that
   gives the platform's own classes (card, row, flash, buttons, forms, tables) the same look, so pages written
   before the theme don't need rewriting.
   Source: resources/theme/ (copied into each portal's assets/theme/ by bin/sync-theme.php). */

/* ─── Starter ─────────────────────────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  /* The platform's own colour names (used in page markup) mapped onto Bootstrap's palette */
  --ink: #212529; --muted: #6c757d; --line: #dee2e6; --hair: #e9ecef; --bg: #f8f9fa; --surface: #fff; --white: #fff;
  --teal: #0d6efd; --teal-soft: #e7f1ff; --pink: #d63384; --pink-soft: #f7d6e6; --orange: #fd7e14; --orange-soft: #ffe5d0;
  --err: #dc3545; --ok: #198754; --warn: #997404; --seashell: #f8f9fa;
}

body { background-color: #f8f9fa; font-size: 0.875rem; }

#wrapper { min-height: 100vh; }
#sidebar-wrapper {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  min-height: 100vh;
  transition: width 0.25s ease, min-width 0.25s ease;
}
.sidebar-brand { white-space: nowrap; }
.sidebar-brand a { color: #fff; text-decoration: none; }

.sidebar-link {
  display: flex; align-items: center; gap: .5rem;
  min-height: 42px; padding: 0.55rem 1rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover, .sidebar-link:focus-visible { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,0.15); color: #fff; border-left-color: #0d6efd; }
.sidebar-link .badge { margin-left: auto; }
.sidebar-link i { width: 1.1rem; text-align: center; }

.sidebar-section {
  padding: 0.55rem 1rem 0.2rem;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.45); margin-top: 0.25rem;
}
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn-link { color: rgba(255,255,255,.75); padding: 0; font-size: .8rem; }

#page-content-wrapper { min-height: 100vh; min-width: 0; overflow-x: hidden; display: flex; flex-direction: column; }
.topbar { gap: .75rem; min-height: 56px; flex-wrap: wrap; }
.topbar .navbar-brand { font-size: 1rem; margin-right: 0; white-space: normal; }
.content { flex: 1 0 auto; }

.card { border-radius: 0.5rem; }
.table th {
  font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: #6c757d;
}

.kpi-card { border-left: 4px solid #0d6efd; }
.kpi-link { transition: transform 0.15s ease, box-shadow 0.15s ease; cursor: pointer; }
.kpi-link:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.12) !important; }

.login-wrapper {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1rem;
  background: linear-gradient(135deg, #1e3a5f 0%, #0d6efd 100%);
}
.login-brand { color: #fff; text-align: center; }
.login-brand .fw-bold { font-size: 1.5rem; }
.login-wrapper .card, .login-card {
  width: 100%; max-width: 400px; border-radius: 1rem; padding: 2.5rem;
  background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-wrapper .flash { width: 100%; max-width: 400px; }
.login-wrapper h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
.login-wrapper .card button[type=submit] { width: 100%; margin-top: 1rem; }
.login-wrapper .card p { margin: 1rem 0 0; }

.btn-xs { font-size: .7rem; padding: .2rem .35rem; line-height: 1.2; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Sidebar: always open on desktop unless collapsed; on phones hidden until opened (the toggle). */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1039; }
@media (min-width: 768px) {
  body.sidebar-collapsed #sidebar-wrapper { width: 0; min-width: 0; overflow: hidden; }
}
@media (max-width: 767.98px) {
  #sidebar-wrapper { position: fixed; z-index: 1040; top: 0; left: 0; height: 100vh; width: 0; min-width: 0; overflow: hidden; }
  body.sidebar-open #sidebar-wrapper { width: var(--sidebar-width); min-width: var(--sidebar-width); overflow-y: auto; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .topbar { padding-left: .75rem !important; padding-right: .75rem !important; }
  .content { padding: 1rem .75rem !important; }
}
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 2000; background: #fff; padding: .5rem .75rem; border-radius: .375rem; }
.skip-link:focus { left: .5rem; }

/* ─── Compatibility: the platform's own classes in the theme's look ───── */
.content { display: grid; gap: 1rem; align-content: start; }
.content > * { min-width: 0; margin-bottom: 0; }
.content h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 .5rem; }
.content h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 .5rem; }
.content h3 { font-size: .95rem; font-weight: 600; }

/* Cards: Bootstrap's .card is a flex column; the platform's are plain blocks with padding. */
.card { display: block; flex-direction: row; background: #fff; border: 0; border-radius: .5rem; box-shadow: 0 .125rem .25rem rgba(0,0,0,.075); padding: 1.25rem; min-width: 0; }
@media (max-width: 600px) { .card { padding: 1rem; } }

/* Rows: Bootstrap's .row is a grid row with gutters; the platform's are wrapping flex lines. */
.row { --bs-gutter-x: 0; --bs-gutter-y: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row > * { width: auto; max-width: 100%; padding: 0; margin-top: 0; flex-shrink: 1; min-width: 0; }

/* Bootstrap's reboot floats legends and makes them large. */
legend { float: none; width: auto; font-size: inherit; font-weight: 600; margin-bottom: .25rem; padding: 0; }
fieldset { min-width: 0; }

/* Messages */
.flash { padding: .75rem 1rem; border: 1px solid transparent; border-radius: .5rem; margin: 0; font-weight: 500; }
.flash.ok { color: #0a3622; background: #d1e7dd; border-color: #a3cfbb; }
.flash.err { color: #58151c; background: #f8d7da; border-color: #f1aeb5; }
.flash.warn { color: #664d03; background: #fff3cd; border-color: #ffe69c; }
.flash.info { color: #055160; background: #cff4fc; border-color: #9eeaf9; }
.flash a { color: inherit; font-weight: 600; }
.muted, .hint { color: #6c757d; }
.hint { font-size: .8rem; margin: .25rem 0 0; }
.error { color: #dc3545; font-size: .8rem; margin: .25rem 0 0; }

/* Forms, as Bootstrap's .form-control / .form-label */
.content label, .login-wrapper label, dialog label { display: block; font-weight: 500; margin: .75rem 0 .25rem; }
.content input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=submit]):not(.form-control),
.content select:not(.form-select), .content textarea:not(.form-control),
.login-wrapper input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
dialog input:not([type=checkbox]):not([type=radio]):not([type=hidden]), dialog select, dialog textarea {
  display: block; width: 100%; min-height: 38px; padding: .375rem .75rem; font: inherit; font-size: .875rem; line-height: 1.5; color: #212529;
  background-color: #fff; border: 1px solid #dee2e6; border-radius: .375rem; transition: border-color .15s, box-shadow .15s;
}
.content input:focus, .content select:focus, .content textarea:focus, .login-wrapper input:focus, dialog input:focus, dialog select:focus, dialog textarea:focus {
  border-color: #86b7fe; outline: 0; box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
}
input[type=checkbox], input[type=radio] { accent-color: #0d6efd; width: 1rem; height: 1rem; }
input[type=file] { font-size: .875rem; }
/* Touch targets of at least 24 px (WCAG 2.5.8): labels, links laid out in a row, icon links in the top bar */
.content label, dialog label { min-height: 24px; }
.content label:has(> input[type=checkbox]), .content label:has(> input[type=radio]) { display: flex; align-items: center; gap: .5rem; }
.content :is(.row, [style*="display:flex"], [style*="display: flex"]) > a { display: inline-flex; align-items: center; min-height: 32px; }
td > input[type=checkbox], th > input[type=checkbox] { width: 1.5rem; height: 1.5rem; }
.pager a { display: inline-flex; align-items: center; min-height: 32px; }
.topbar a.position-relative { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; }

/* Buttons: plain buttons and the platform's .btn become Bootstrap primary; .secondary outline; .link a link. */
button:not([class*="btn-"]):not(.sidebar-toggle):not(.navbar-toggler), .btn:not([class*="btn-"]) {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem; min-height: 38px; margin: 0;
  padding: .375rem .75rem; font: inherit; font-size: .875rem; font-weight: 500; line-height: 1.5; text-decoration: none; cursor: pointer;
  color: #fff; background: #0d6efd; border: 1px solid #0d6efd; border-radius: .375rem; box-shadow: none; transition: background .15s, border-color .15s;
}
button:not([class*="btn-"]):not(.sidebar-toggle):not(.navbar-toggler):hover, .btn:not([class*="btn-"]):hover { background: #0b5ed7; border-color: #0a58ca; color: #fff; }
button.secondary, .btn.secondary { color: #495057 !important; background: #fff !important; border-color: #adb5bd !important; }
button.secondary:hover, .btn.secondary:hover { background: #6c757d !important; border-color: #6c757d !important; color: #fff !important; }
button.pink, .btn.pink { background: #d63384 !important; border-color: #d63384 !important; }
button.link { background: none !important; border: 0 !important; color: #0d6efd !important; padding: .25rem .5rem; min-height: 0; text-decoration: underline; font-weight: 500; }
button:disabled, .btn[aria-disabled="true"] { opacity: .65; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 0; box-shadow: 0 0 0 .25rem rgba(13,110,253,.35); }

/* Tables without Bootstrap classes get the theme's table look (uppercase grey headings, hover rows). */
.content table:not(.table) { width: 100%; border-collapse: collapse; font-size: .85rem; margin: 0; }
.content table:not(.table) th { font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; background: #f8f9fa;
  border-bottom: 1px solid #dee2e6; padding: .5rem .6rem; text-align: left; vertical-align: bottom; }
.content table:not(.table) td { padding: .5rem .6rem; border-bottom: 1px solid #dee2e6; vertical-align: top; }
.content table:not(.table) tbody tr:hover > td { background: rgba(0,0,0,.025); }
.content td.num, .content th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; position: relative; }

/* Status labels (pill / tag) as Bootstrap badges */
.pill, .tag { display: inline-block; padding: .25em .6em; font-size: .72rem; font-weight: 600; line-height: 1.2; border-radius: 50rem; border: 0;
  background: #e9ecef; color: #495057; text-transform: none; letter-spacing: 0; vertical-align: .05em; }

/* The platform's toast (renamed from .toast, which Bootstrap hides until .show) in the starter's look */
.sf-toast { position: fixed; top: 1rem; right: 1rem; left: auto; bottom: auto; transform: none; z-index: 9999; margin: 0; min-width: 240px; max-width: calc(100vw - 2rem);
  padding: .75rem 1.25rem; border: 0; border-radius: .5rem; color: #fff; background: #198754; font-size: .875rem; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slideIn .25s ease; }
.sf-toast.err { background: #dc3545; }
.sf-toast a { color: #fff; }

/* Dialogs (account menu, basket drawer, support panel) as Bootstrap off-canvas panels */
dialog { border: 0; border-radius: 0; box-shadow: -4px 0 24px rgba(0,0,0,.15); color: #212529; }
dialog::backdrop { background: rgba(0,0,0,.4); }

@media print {
  #sidebar-wrapper, .topbar, .no-print, .flash, .sidebar-backdrop { display: none !important; }
  body { background: #fff; } .card { box-shadow: none; border: 1px solid #dee2e6; break-inside: avoid; }
}
