/* ============================================================
   BioDrive — Shared Stylesheet
   AI-powered pharmaceutical replenishment platform
   Aesthetic: strictly TEAL + WHITE
   - White backgrounds
   - Teal variations for borders, buttons, accents
   - Dark grey / teal text for readability
   Layout strategy: Flexbox for page shell, CSS Grid for widgets
   ============================================================ */

/* ----------------------------------------------------------
   1. Design Tokens (CSS Custom Properties)
   Centralised teal palette so the whole UI stays consistent.
   ---------------------------------------------------------- */
:root {
  /* Teal scale (light -> dark) */
  --teal-50:  #e6f4f3;   /* tint backgrounds / hover fills */
  --teal-100: #c9e8e6;   /* subtle surfaces */
  --teal-200: #9ed6d3;   /* borders */
  --teal-300: #66bcb8;   /* secondary accents */
  --teal-500: #168f88;   /* primary brand teal */
  --teal-600: #0f766e;   /* buttons / strong accents */
  --teal-700: #0b5a54;   /* button hover / headings */
  --teal-900: #08403c;   /* deep teal for sidebar */

  /* Neutrals */
  --white:    #ffffff;
  --grey-50:  #f7faf9;   /* app canvas background */
  --grey-200: #e2e8e7;   /* hairline dividers */
  --text-dark:  #1f2b2a; /* primary readable text (dark grey) */
  --text-muted: #5c6b6a; /* secondary text */

  /* Status helpers (kept within teal/neutral family) */
  --ok:    var(--teal-600);
  --warn:  #b08400;      /* amber, used sparingly for low stock */
  --danger:#a23b3b;      /* muted red, critical only */

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(8, 64, 60, 0.08);
  --sidebar-width: 260px;
}

/* ----------------------------------------------------------
   2. Base Reset & Typography
   ---------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--grey-50);
  color: var(--text-dark);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ----------------------------------------------------------
   3. Page Shell — Flexbox
   Fixed sidebar on the left, scrollable main content on right.
   ---------------------------------------------------------- */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;          /* fixed left-hand navigation */
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--teal-900);
  color: var(--teal-50);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

/* Brand / logo block */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand__mark {
  width: 48px;
  height: auto;
  aspect-ratio: 513 / 238;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand__name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand__sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--teal-200);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Navigation list */
.nav {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 14px;
}

.nav__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--teal-300);
  padding: 14px 12px 6px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--teal-50);
  font-size: 14.5px;
  transition: background-color 0.15s ease;
}

.nav__item:hover {
  background-color: rgba(255, 255, 255, 0.07);
}

/* Active route highlight uses brand teal */
.nav__item--active {
  background-color: var(--teal-600);
  font-weight: 600;
}

.nav__icon {
  width: 18px;
  text-align: center;
  opacity: 0.9;
}

/* User card pinned to bottom of sidebar */
.sidebar__footer {
  margin-top: auto;
  padding: 16px 24px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--teal-500);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.sidebar__footer small {
  display: block;
  color: var(--teal-300);
  font-size: 12px;
}

.sidebar__meta {
  padding: 12px 24px 20px;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.4);
}

.sidebar__meta button {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--teal-300);
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Main content column ---- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width); /* clears the fixed sidebar */
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top header bar inside main */
.topbar {
  background-color: var(--white);
  border-bottom: 1px solid var(--grey-200);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  font-size: 22px;
  color: var(--text-dark);
}

.topbar p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 28px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ----------------------------------------------------------
   4. Buttons
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Primary — solid teal */
.btn--primary {
  background-color: var(--teal-600);
  color: var(--white);
}
.btn--primary:hover {
  background-color: var(--teal-700);
}

/* Outline — teal border on white */
.btn--outline {
  background-color: var(--white);
  color: var(--teal-700);
  border-color: var(--teal-200);
}
.btn--outline:hover {
  background-color: var(--teal-50);
  border-color: var(--teal-300);
}

/* Subtle/ghost button */
.btn--ghost {
  background-color: transparent;
  color: var(--teal-50);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn--ghost:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn--sm {
  padding: 7px 13px;
  font-size: 13px;
}

.btn--block {
  width: 100%;
}

/* ----------------------------------------------------------
   5. Cards / Widgets
   ---------------------------------------------------------- */
.card {
  background-color: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--grey-200);
}

.card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--teal-700);
}

.card__title .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--teal-500);
}

.card__sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.card__body {
  padding: 22px;
  /* Every wide table in the app (Order Queue, Dispatch, Clinic Stock, etc.)
     lives inside a card body — scrolling it here, rather than the whole
     page scrolling sideways, is what keeps narrow/mobile layouts intact. */
  overflow-x: auto;
}

/* Two-column responsive widget row via Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

/* ----------------------------------------------------------
   6. Alerts Banner
   ---------------------------------------------------------- */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-left: 5px solid var(--teal-600);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.alert-banner__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--teal-600);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.alert-banner__text strong {
  color: var(--teal-700);
}

.alert-banner__text p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.alert-banner__count {
  margin-left: auto;
  background-color: var(--teal-600);
  color: var(--white);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}

/* ----------------------------------------------------------
   7. Patient list
   ---------------------------------------------------------- */
.patient {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--grey-200);
}
.patient:last-child {
  border-bottom: none;
}

.patient__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--teal-100);
  color: var(--teal-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.patient__info {
  flex: 1;
  min-width: 0;
}

.patient__name {
  font-weight: 600;
  font-size: 14.5px;
}

.patient__meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

.tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background-color: var(--teal-50);
  color: var(--teal-700);
  border: 1px solid var(--teal-200);
  white-space: nowrap;
}

/* ----------------------------------------------------------
   8. AI Recommendation rows
   ---------------------------------------------------------- */
.reco {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.reco:last-of-type {
  margin-bottom: 0;
}

.reco__drug {
  flex: 1;
  min-width: 0;
}
.reco__drug strong {
  font-size: 14.5px;
}
.reco__drug span {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
}

.reco__qty {
  text-align: center;
  padding: 0 8px;
}
.reco__qty b {
  display: block;
  font-size: 20px;
  color: var(--teal-700);
}
.reco__qty small {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* AI confidence meter */
.meter {
  width: 110px;
  flex-shrink: 0;
}
.meter small {
  font-size: 11px;
  color: var(--text-muted);
}
.meter__track {
  height: 7px;
  border-radius: 999px;
  background-color: var(--teal-50);
  overflow: hidden;
  margin-top: 4px;
}
.meter__fill {
  height: 100%;
  background-color: var(--teal-500);
}

/* ----------------------------------------------------------
   9. Inventory grid (Warehouse)
   ---------------------------------------------------------- */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.stock-card {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  padding: 16px;
  background-color: var(--white);
}

.stock-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.stock-card__name {
  font-weight: 700;
  font-size: 14.5px;
}
.stock-card__sku {
  font-size: 11.5px;
  color: var(--text-muted);
}

.stock-card__qty {
  font-size: 26px;
  font-weight: 700;
  color: var(--teal-700);
}
.stock-card__unit {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Status pills */
.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pill--ok {
  background-color: var(--teal-50);
  color: var(--teal-700);
  border: 1px solid var(--teal-200);
}
.pill--low {
  background-color: #fdf6e3;
  color: var(--warn);
  border: 1px solid #ecd9a0;
}
.pill--critical {
  background-color: #fbeaea;
  color: var(--danger);
  border: 1px solid #e7bcbc;
}

/* Stock level bar */
.level {
  margin-top: 12px;
}
.level__track {
  height: 8px;
  border-radius: 999px;
  background-color: var(--grey-200);
  overflow: hidden;
}
.level__fill {
  height: 100%;
  background-color: var(--teal-500);
}
.level__fill--low {
  background-color: var(--warn);
}
.level__fill--critical {
  background-color: var(--danger);
}

/* ----------------------------------------------------------
   10. Incoming orders table
   ---------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--grey-200);
}

.table td {
  padding: 14px;
  border-bottom: 1px solid var(--grey-200);
  font-size: 14px;
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background-color: var(--grey-50);
}

.order-id {
  font-weight: 700;
  color: var(--teal-700);
}

.muted {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ----------------------------------------------------------
   11. KPI stat strip
   ---------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat {
  background-color: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat__label {
  font-size: 12.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--teal-700);
  margin-top: 4px;
}
.stat__trend {
  font-size: 12.5px;
  color: var(--teal-600);
  margin-top: 2px;
}

/* Pages cross-link helper */
.switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--teal-700);
  border: 1px solid var(--teal-200);
  background-color: var(--white);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}
.switcher:hover {
  background-color: var(--teal-50);
}

/* ----------------------------------------------------------
   12. Inline-editable table controls
   Used where a table cell needs to be edited in place (e.g. Warehouse
   Inventory thresholds) instead of opening a separate form.
   ---------------------------------------------------------- */
.table-input {
  width: 88px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  color: var(--text-dark);
}

.table-input:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 2px var(--teal-50);
}

.table__actions {
  display: flex;
  gap: 8px;
}

/* Shown in place of a table/list when there's nothing to display yet
   (e.g. no pending orders) — keeps empty pages from looking broken. */
.empty-state {
  padding: 36px 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ----------------------------------------------------------
   13. Simple bar chart (GP Reporting — recent delivery volumes)
   Deliberately plain: a handful of real, small numbers reads better as a
   short bar chart than as a fabricated smooth trend line would.
   ---------------------------------------------------------- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  min-height: 170px;
}

.bar-chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bar-chart__value {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-700);
}

.bar-chart__bar {
  width: 100%;
  max-width: 44px;
  background-color: var(--teal-500);
  border-radius: 6px 6px 0 0;
}

.bar-chart__label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ----------------------------------------------------------
   Remote Access Command Center
   ---------------------------------------------------------- */
.cluster-list,
.stop-list {
  display: grid;
  gap: 12px;
}

.cluster,
.allocation-row,
.route-block,
.stop-row {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  background-color: var(--white);
}

.cluster,
.allocation-row,
.stop-row {
  padding: 12px 14px;
}

.cluster strong,
.allocation-row strong,
.route-block strong,
.stop-row strong {
  display: block;
  color: var(--text-dark);
}

.cluster small,
.allocation-row small,
.route-block small,
.stop-row small {
  display: block;
  color: var(--text-muted);
  margin-top: 3px;
}

.cluster__meta,
.route-block__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cluster__meta span,
.route-block__meta span {
  font-size: 12px;
  color: var(--teal-700);
  background-color: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-radius: 999px;
  padding: 4px 8px;
}

.cluster p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 10px;
}

.allocation-row,
.route-block__head,
.stop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-block {
  padding: 14px;
}

.route-block + .route-block {
  margin-top: 14px;
}

.route-block__head {
  margin-bottom: 10px;
}

.route-block__meta {
  margin-bottom: 14px;
}

.stop-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
}

/* ----------------------------------------------------------
   14. Responsive — collapse layout on small screens
   ---------------------------------------------------------- */
@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr; /* stack widgets */
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  /* Sidebar becomes a top bar, content flows full width */
  .app {
    flex-direction: column;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 16px;
  }
  .brand {
    border-bottom: none;
    padding: 0;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0;
    margin-left: auto;
    padding: 0;
    gap: 6px;
  }
  .nav__label,
  .sidebar__footer {
    display: none;
  }
  .nav__item {
    padding: 8px 12px;
  }
  .main {
    margin-left: 0;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .stop-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }
  .stop-row .pill,
  .stop-row .btn {
    grid-column: 2;
    justify-self: flex-start;
  }
}
