/* ==========================================================================
   iHospital theme layer — loaded AFTER vendor/bootstrap/bootstrap.min.css.

   Bootstrap 5.3 owns the reset, grid, components and utilities. This file
   does three things and nothing else:
     1. re-points Bootstrap's own CSS variables at the brand palette
     2. keeps the --c-* tokens the app's other stylesheets already use
     3. defines the components Bootstrap has no equivalent for
   Where a rule duplicates something Bootstrap already provides, it is here
   only because our markup uses bare elements (e.g. <input>) that Bootstrap
   does not style without a .form-control class.
   ========================================================================== */

:root {
  /* ---- Brand tokens (used across admin.css, shop.css, pos.css, …) ---- */
  --c-bg:            #ffffff;
  --c-surface:       #ffffff;
  --c-surface-2:     #f4f4f4;
  --c-surface-3:     #e8e8e8;
  --c-border:        #e0e0e0;
  --c-border-strong: #bdbdbd;
  --c-ink:           #000000;
  --c-ink-2:         #2b2b2b;
  --c-ink-3:         #6e6e6e;
  --c-ink-invert:    #ffffff;

  --c-brand:         #e41c21;   /* the red from the iHospital mark */
  --c-brand-ink:     #ffffff;
  --c-brand-dark:    #b5151a;
  --c-brand-soft:    #fdecec;
  --c-accent:        #e41c21;
  --c-accent-soft:   #fdecec;

  --c-black:         #000000;
  --c-black-2:       #141414;
  --c-black-3:       #262626;
  --c-on-black:      #ffffff;
  --c-on-black-2:    #b8b8b8;

  --c-ok:            #1a7f4b;  --c-ok-soft:     #eaf4ee;
  --c-warn:          #8a5a00;  --c-warn-soft:   #fbf1e0;
  --c-danger:        #c1121f;  --c-danger-soft: #fdeaeb;
  --c-info:          #1f1f1f;  --c-info-soft:   #f0f0f0;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem; --fs-sm: 0.8125rem; --fs-base: 0.9375rem; --fs-md: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem; --fs-3xl: 2.25rem; --fs-4xl: 3rem;
  --lh-tight: 1.2; --lh-base: 1.55;

  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4rem;
  --r-sm: 3px; --r-md: 5px; --r-lg: 8px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-2: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-3: 0 12px 32px rgba(0,0,0,.16);
  --ring: 0 0 0 3px rgba(228,28,33,.25);
  --maxw: 1240px;
  --transition: 140ms cubic-bezier(.4,0,.2,1);

  /* ---- Re-point Bootstrap at the brand ---- */
  --bs-primary:            #e41c21;
  --bs-primary-rgb:        228, 28, 33;
  --bs-primary-text-emphasis: #b5151a;
  --bs-primary-bg-subtle:  #fdecec;
  --bs-primary-border-subtle: #f6b9bb;
  --bs-link-color:         #e41c21;
  --bs-link-color-rgb:     228, 28, 33;
  --bs-link-hover-color:   #b5151a;
  --bs-body-bg:            #ffffff;
  --bs-body-color:         #000000;
  --bs-body-color-rgb:     0, 0, 0;
  --bs-secondary-color:    rgba(0, 0, 0, .62);
  --bs-tertiary-color:     rgba(0, 0, 0, .48);
  --bs-tertiary-bg:        #f4f4f4;
  --bs-secondary-bg:       #e8e8e8;
  --bs-border-color:       #e0e0e0;
  --bs-border-color-translucent: rgba(0, 0, 0, .1);
  --bs-emphasis-color:     #000000;
  --bs-body-font-family:   var(--font-sans);
  --bs-body-font-size:     0.9375rem;
  --bs-body-line-height:   1.55;
  --bs-border-radius:      5px;
  --bs-border-radius-sm:   3px;
  --bs-border-radius-lg:   8px;
  --bs-border-radius-xl:   12px;
  --bs-focus-ring-color:   rgba(228, 28, 33, .25);
  --bs-heading-color:      inherit;   /* inherit, so headings on dark panels stay legible */
  --bs-code-color:         #b5151a;
}

/* Bootstrap's .btn-primary reads these per-component variables. */
.btn-primary {
  --bs-btn-bg: #e41c21;            --bs-btn-border-color: #e41c21;
  --bs-btn-hover-bg: #b5151a;      --bs-btn-hover-border-color: #b5151a;
  --bs-btn-active-bg: #9c1216;     --bs-btn-active-border-color: #9c1216;
  --bs-btn-disabled-bg: #e41c21;   --bs-btn-disabled-border-color: #e41c21;
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: #e41c21;         --bs-btn-border-color: #e41c21;
  --bs-btn-hover-bg: #e41c21;      --bs-btn-hover-border-color: #e41c21;
  --bs-btn-active-bg: #b5151a;     --bs-btn-active-border-color: #b5151a;
}
.btn-dark {
  --bs-btn-bg: #000; --bs-btn-border-color: #000;
  --bs-btn-hover-bg: #262626; --bs-btn-hover-border-color: #262626;
}
.text-primary { color: var(--c-brand) !important; }
.bg-primary   { background-color: var(--c-brand) !important; }
.border-primary { border-color: var(--c-brand) !important; }
.form-control:focus, .form-select:focus { border-color: var(--c-brand); box-shadow: var(--ring); }
.form-check-input:checked { background-color: var(--c-brand); border-color: var(--c-brand); }
.nav-link { --bs-nav-link-color: var(--c-ink-2); --bs-nav-link-hover-color: var(--c-brand); }
.page-link { --bs-pagination-color: var(--c-ink-2); --bs-pagination-active-bg: var(--c-brand); --bs-pagination-active-border-color: var(--c-brand); --bs-pagination-focus-box-shadow: var(--ring); }
::selection { background: rgba(228, 28, 33, .18); }

html, body { overflow-x: clip; }   /* clip, not hidden: keeps position:sticky working */
body { -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
/* Anything that is a control rather than prose never gets an underline. */
.btn:hover, .nav-link:hover, .navbar-brand:hover, .page-link:hover,
.site-nav a:hover, .admin-nav a:hover, .tabs a:hover, .product-card a:hover,
.site-logo:hover, .admin-brand:hover, .dropdown-item:hover { text-decoration: none; }
h1,h2,h3,h4,h5 { font-weight: 650; letter-spacing: -.011em; line-height: var(--lh-tight); }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }  h4 { font-size: var(--fs-md); }
code, kbd, pre, .mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
img { max-width: 100%; height: auto; }

/* ==========================================================================
   Layout helpers the app's markup depends on
   ========================================================================== */
/* One gutter scale everywhere, so nothing sits flush to the edge and the left
   and right margins always match. Bootstrap's --bs-gutter-x is the TOTAL, so
   each side gets half: 24px desktop, 20px tablet, 16px phone. */
.container, .container-fluid { max-width: var(--maxw); --bs-gutter-x: 3rem; }
@media (max-width: 991.98px) { .container, .container-fluid { --bs-gutter-x: 2.5rem; } }
@media (max-width: 575.98px) { .container, .container-fluid { --bs-gutter-x: 2rem; } }
/* Belt and braces: some markup uses .container without Bootstrap's gutter vars. */
.container { padding-inline: calc(var(--bs-gutter-x) * .5); }
.stack > * + * { margin-top: var(--sp-4); }
/* Our horizontal flex line. Named hrow because .row is Bootstrap's grid row. */
.hrow { display: flex; gap: var(--sp-3); align-items: center; }
.hrow-between { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.hrow-wrap { flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.spacer { flex: 1; }
.text-right { text-align: right; }
.muted { color: var(--c-ink-3); }
.dim { color: var(--c-ink-2); }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-4 { margin-top: var(--sp-4); } .mb-4 { margin-bottom: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); } .mb-5 { margin-bottom: var(--sp-5); }

/* ==========================================================================
   Button variants Bootstrap does not ship
   ========================================================================== */
.btn { font-weight: 560; }
.btn-secondary {
  --bs-btn-bg: #fff; --bs-btn-color: var(--c-ink); --bs-btn-border-color: var(--c-border-strong);
  --bs-btn-hover-bg: var(--c-surface-2); --bs-btn-hover-color: var(--c-ink); --bs-btn-hover-border-color: var(--c-border-strong);
  --bs-btn-active-bg: var(--c-surface-3); --bs-btn-active-color: var(--c-ink); --bs-btn-active-border-color: var(--c-border-strong);
}
.btn-ghost {
  --bs-btn-bg: transparent; --bs-btn-color: var(--c-ink-2); --bs-btn-border-color: transparent;
  --bs-btn-hover-bg: var(--c-surface-3); --bs-btn-hover-color: var(--c-ink); --bs-btn-hover-border-color: transparent;
}
.btn-accent { --bs-btn-bg: var(--c-accent); --bs-btn-color: #fff; --bs-btn-border-color: var(--c-accent); --bs-btn-hover-bg: var(--c-brand-dark); --bs-btn-hover-border-color: var(--c-brand-dark); --bs-btn-hover-color: #fff; }
/* Bootstrap's .btn is inline-block and centres via text-align, so switching to
   flex here loses that — the label falls to the left edge without an explicit
   justification. */
.btn-block { display: flex; width: 100%; justify-content: center; align-items: center; }
.btn-icon { padding: .4rem; aspect-ratio: 1; }

/* ==========================================================================
   Bare form elements — our markup uses <input> without .form-control,
   which Bootstrap leaves unstyled, so they are given the same treatment.
   ========================================================================== */
.field { display: block; margin-bottom: var(--sp-4); }
.field > label, .label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); font-weight: 600; color: var(--c-ink-2); }
.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%; padding: .45rem .7rem; font: inherit; font-size: var(--fs-base);
  color: var(--c-ink); background: #fff; border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md); transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--c-surface-2); color: var(--c-ink-3); }
textarea { min-height: 7rem; resize: vertical; }
select:not([multiple]):not([size]) {
  appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e6e' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right .55rem center; background-size: 1rem;
}
.input-error { border-color: var(--c-danger) !important; }
.field-error { display: block; margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--c-danger); }
.field-hint  { display: block; margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--c-ink-3); }
.checkbox, .radio { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-base); }
.checkbox input, .radio input { width: auto; margin-top: .2rem; accent-color: var(--c-brand); }
.input-money { font-family: var(--font-mono); text-align: right; }
fieldset { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-4); margin: 0 0 var(--sp-4); }
legend { padding-inline: var(--sp-2); font-size: var(--fs-sm); font-weight: 650; color: var(--c-ink-2); float: none; width: auto; }

/* ==========================================================================
   Cards — Bootstrap owns .card/.card-body; these are our extra slots
   ========================================================================== */
.card { --bs-card-border-color: var(--c-border); --bs-card-border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-pad { padding: var(--sp-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }
.card-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ==========================================================================
   Tables — Bootstrap styles .table; this is the house treatment on top.
   .table-wrap keeps wide financial tables scrollable on small screens.
   ========================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
.table { --bs-table-border-color: var(--c-border); --bs-table-hover-bg: var(--c-surface-2); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table > thead th {
  font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--c-ink-3); background: var(--c-surface-2); white-space: nowrap; border-bottom-width: 1px;
}
.table tbody tr:hover { background: var(--c-surface-2); }
.table .num, .table .money { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 650; background: var(--c-surface-2); border-top: 2px solid var(--c-border-strong); }
.table-compact > :not(caption) > * > * { padding: .35rem .5rem; font-size: var(--fs-sm); }
.table-empty { padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--c-ink-3); }

/* ==========================================================================
   Badges, alerts, and the rest of the house components
   ========================================================================== */
.badge { display: inline-flex; align-items: center; gap: .3em; padding: .15rem .5rem; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 650; letter-spacing: .02em; white-space: nowrap; background: var(--c-surface-3); color: var(--c-ink-2); }
.badge-ok { background: var(--c-ok-soft); color: var(--c-ok); }
.badge-warn { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-info { background: var(--c-info-soft); color: var(--c-info); }
.badge-brand { background: var(--c-brand-soft); color: var(--c-brand-dark); }

.alert { display: flex; gap: var(--sp-3); align-items: flex-start; border: 1px solid transparent; }
.alert-success { background: var(--c-ok-soft); border-color: #bfe0cd; color: #145f38; }
.alert-error, .alert-danger { background: var(--c-danger-soft); border-color: #f2c3c6; color: #90101a; }
.alert-warning { background: var(--c-warn-soft); border-color: #ecd9b0; color: #6f4900; }
.alert-info { background: var(--c-info-soft); border-color: #d8d8d8; color: var(--c-ink-2); }

.flash-stack { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 1080; width: min(24rem, calc(100vw - 2rem)); }
.flash-stack .alert { box-shadow: var(--shadow-2); }

.pagination { --bs-pagination-border-color: var(--c-border); flex-wrap: wrap; gap: var(--sp-1); align-items: center; margin-top: var(--sp-5); }
.pagination a, .pagination span { padding: .35rem .7rem; border-radius: var(--r-sm); font-size: var(--fs-sm); border: 1px solid var(--c-border); background: #fff; color: var(--c-ink-2); text-decoration: none; }
.pagination a:hover { background: var(--c-surface-2); }
.pagination .is-current { background: var(--c-brand); border-color: var(--c-brand); color: #fff; font-weight: 650; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }

.stat { padding: var(--sp-4); background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-lg); }
.stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--c-ink-3); font-weight: 650; }
.stat-value { font-size: var(--fs-2xl); font-weight: 680; font-family: var(--font-mono); font-variant-numeric: tabular-nums; margin-top: var(--sp-1); letter-spacing: -.02em; overflow-wrap: anywhere; }
.stat-meta { font-size: var(--fs-sm); color: var(--c-ink-3); margin-top: var(--sp-1); }
.stat-up { color: var(--c-ok); } .stat-down { color: var(--c-danger); }

.empty-state { padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--c-ink-3); }
.empty-state h3 { color: var(--c-ink-2); }
.divider { height: 1px; background: var(--c-border); margin: var(--sp-5) 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.kbd { padding: .1rem .35rem; font-size: var(--fs-xs); border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--c-surface-2); }
.skeleton { background: linear-gradient(90deg, var(--c-surface-2), var(--c-surface-3), var(--c-surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Small screens: never let a wide table push the page sideways
   ========================================================================== */
@media (max-width: 575.98px) {
  :root { --fs-2xl: 1.5rem; --fs-3xl: 1.75rem; --fs-4xl: 2.125rem; }
  .card-pad, .card-body, .card-head, .card-foot { padding: var(--sp-4); }
  .stat-value { font-size: var(--fs-xl); }
  .flash-stack { left: var(--sp-3); right: var(--sp-3); width: auto; }
}

@media print {
  body { background: #fff; }
  .no-print, .flash-stack, nav, .site-header, .admin-sidebar, .navbar { display: none !important; }
  .card { border: 0; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
