/*
 * DocDock design system
 * ---------------------
 * The dashboard settled the app's visual language: a card with a tinted icon
 * beside a title and a one-line subtitle, tiles rather than nested cards,
 * segmented controls for single choices, and an illustrated empty state instead
 * of grey text in the middle of a body. Those pieces lived in DashboardPage's
 * scoped styles, so every other page reinvented its own version of each.
 *
 * They live here now, as plain global classes, and every page uses them. Loaded
 * last in index.html so it wins over the vendor theme without !important.
 */

:root {
  --ds-primary: #1f6db2;
  --ds-primary-dark: #17568c;
  --ds-ink: #0f172a;
  --ds-body: #334155;
  --ds-muted: #64748b;
  --ds-faint: #94a3b8;
  --ds-line: #e2e8f0;
  --ds-line-soft: #eef2f7;
  --ds-surface: #fbfcfe;
  --ds-hover: #f8fafc;
  --ds-radius-lg: 0.9rem;
  --ds-radius: 0.7rem;
  --ds-radius-sm: 0.5rem;
  --ds-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05);
  --ds-shadow-lg: 0 16px 32px rgba(15, 23, 42, 0.12);
}

/* ---------------------------------------------------------------- *
 * Surfaces
 * ---------------------------------------------------------------- */

.card {
  border: 1px solid #e8eef6;
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow);
}

.card > .card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--ds-line-soft);
  background: transparent;
  border-top-left-radius: var(--ds-radius-lg);
  border-top-right-radius: var(--ds-radius-lg);
}

.card > .card-body {
  padding: 1.25rem;
}

/* `.section-card` was `border: 0` in the old theme overrides, which left the
   dashboard's cards floating. They carry the same edge as everything else. */
.section-card {
  border: 1px solid #e8eef6;
}

@media (max-width: 575.98px) {
  .card > .card-header {
    padding: 0.8rem 0.9rem;
  }

  .card > .card-body {
    padding: 0.9rem;
  }
}

/* ---------------------------------------------------------------- *
 * Page heading
 *
 * One block at the top of every page: what the page is, one line saying what
 * it covers, and the page's primary action pinned right. Replaces the mix of
 * bare h4s, breadcrumb trails and pages that opened straight onto a card.
 * ---------------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.page-head-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--ds-radius);
  font-size: 1.35rem;
}

.page-head-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-head-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ds-ink);
  line-height: 1.25;
}

.page-head-sub {
  font-size: 0.8125rem;
  color: var(--ds-muted);
}

/* The actions never wrap under the title on their own; they take a row of their
   own only once the whole head has run out of width. Right-aligned so that when
   they do wrap internally, the rows stay flush with the edge of the page. */
.page-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

@media (max-width: 767.98px) {
  .page-head-icon {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }

  .page-head-title {
    font-size: 1.1rem;
  }

  .page-head-actions {
    width: 100%;
  }

  .page-head-actions > .btn {
    flex: 1 1 auto;
  }
}

/* ---------------------------------------------------------------- *
 * Card heading
 * ---------------------------------------------------------------- */

.card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.card-head-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--ds-radius);
  font-size: 1.15rem;
}

.card-head-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-head-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ds-ink);
  line-height: 1.25;
}

.card-head-sub {
  font-size: 0.8125rem;
  color: var(--ds-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Actions that belong to a card rather than to the page. */
.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

@media (max-width: 575.98px) {
  .card-head-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .card-head-sub {
    white-space: normal;
  }
}

/* ---------------------------------------------------------------- *
 * Icon tones
 *
 * Named by colour rather than by feature, so a card can be renamed without its
 * tile changing hue -- and so two screens showing the same kind of thing can
 * deliberately share one.
 * ---------------------------------------------------------------- */

.tone-blue { background: #e8f0ff; color: #1f6db2; }
.tone-violet { background: #ede9fe; color: #6d4aff; }
.tone-sky { background: #e0f2fe; color: #0284c7; }
.tone-green { background: #dcf5ee; color: #00805f; }
.tone-amber { background: #ffedd5; color: #ea580c; }
.tone-rose { background: #ffe4e6; color: #be123c; }
.tone-teal { background: #ccfbf1; color: #0f766e; }
.tone-slate { background: #eef2f7; color: #475569; }

/* ---------------------------------------------------------------- *
 * Stat tiles
 *
 * Tiles, not cards: the surrounding card is the boundary, and nesting a card
 * inside a card is what made neighbouring sections run together.
 * ---------------------------------------------------------------- */

/* auto-fit rather than fixed columns: the tiles go 4 / 2 / 1 across on their
   own as the viewport narrows, with no breakpoint to keep in sync. The 132px
   floor is what lets two fit inside the card padding on a 390px phone. */
.kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.kpi-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--ds-line-soft);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
}

.kpi-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--ds-radius);
  font-size: 1.25rem;
}

.kpi-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ds-ink);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
  /* Two tiles across leaves ~75px beside the icon, which is not enough for
     "APPOINTMENTS" -- it broke mid-word. Stacking hands the label the tile's
     whole width and keeps working for the longer French labels too. */
  .kpi-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.7rem;
    gap: 0.45rem;
  }

  .kpi-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .kpi-text {
    width: 100%;
  }

  .kpi-value {
    font-size: 1.25rem;
  }
}

/* ---------------------------------------------------------------- *
 * Field list
 *
 * The read-only counterpart to a form: a label above the value it describes,
 * reflowing rather than scrolling sideways.
 * ---------------------------------------------------------------- */

.field-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field-grid-wide {
  grid-column: 1 / -1;
}

.field-label {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

.field-value {
  min-height: 42px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ds-line-soft);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
  color: var(--ds-ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.field-value-notes {
  white-space: pre-wrap;
  font-weight: 500;
}

/* ---------------------------------------------------------------- *
 * Segmented control
 *
 * One track holding every choice, so it reads as the single-choice control it
 * is rather than as N buttons that happen to be in a row.
 * ---------------------------------------------------------------- */

.seg {
  display: flex;
  gap: 0.15rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--ds-line-soft);
  /* Below ~380px the labels cannot all fit; scrolling the track beats wrapping
     it into a second row that pushes the cards down. */
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ds-ink);
}

.seg-btn.is-active {
  background: #fff;
  color: var(--ds-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

/* Icon-only variant, for view switchers where the label is a tooltip. */
.seg-btn-icon {
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
}

/* The label that introduces a segmented control. */
.seg-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

/* ---------------------------------------------------------------- *
 * Toolbar
 *
 * The filter row above a table or grid. A bar rather than a card: it acts on
 * what follows instead of being a section of its own.
 * ---------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid #e8eef6;
  border-radius: var(--ds-radius-lg);
  background: #fff;
  box-shadow: var(--ds-shadow);
}

.toolbar-search {
  flex: 1 1 16rem;
  min-width: 0;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

/* A search box with the magnifier inside the field rather than in a bolted-on
   input-group addon, so it lines up with the plain selects beside it. */
.search-field {
  position: relative;
  min-width: 0;
}

.search-field > i {
  position: absolute;
  top: 50%;
  inset-inline-start: 0.75rem;
  transform: translateY(-50%);
  color: var(--ds-faint);
  pointer-events: none;
}

.search-field > .form-control {
  padding-inline-start: 2.25rem;
}

/* ---------------------------------------------------------------- *
 * Empty state
 * ---------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3rem 1rem;
  color: var(--ds-faint);
  text-align: center;
}

.empty-state i {
  font-size: 2rem;
}

.empty-state-sm {
  padding: 1.75rem 1rem;
}

.empty-state-sm i {
  font-size: 1.5rem;
}

/* Same treatment for a table that came back with no rows. */
.empty-state-cell {
  padding: 0 !important;
}

/* ---------------------------------------------------------------- *
 * Count badge
 *
 * The number beside a section title. Red was reserved for something being
 * wrong; a count of documents on a patient is not that.
 * ---------------------------------------------------------------- */

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e8f0ff;
  color: var(--ds-primary);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- *
 * Avatars
 * ---------------------------------------------------------------- */

.ds-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ds-primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}

.ds-avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.7rem;
}

.ds-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: var(--ds-radius-lg);
  font-size: 1.25rem;
}

.ds-avatar-xl {
  width: 84px;
  height: 84px;
  border-radius: var(--ds-radius-lg);
  font-size: 1.65rem;
}

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

.table > :not(caption) > * > * {
  padding: 0.75rem 1rem;
}

.table > thead th,
.table > thead td {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--ds-line);
  background: var(--ds-hover);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-muted);
  white-space: nowrap;
}

/* The sortable headers are buttons; they inherit the heading's own type rather
   than Bootstrap's link styling. */
.table > thead th .btn-link {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}

.table > thead th .btn-link:hover {
  color: var(--ds-ink);
}

.table > tbody > tr > * {
  border-bottom: 1px solid var(--ds-line-soft);
  color: var(--ds-body);
}

.table > tbody > tr:last-child > * {
  border-bottom: 0;
}

.table-hover > tbody > tr:hover > * {
  background-color: var(--ds-hover);
}

/* A table filling a card body edge to edge keeps its rounded bottom corners. */
.card > .card-body.p-0 > .table-responsive {
  border-bottom-left-radius: var(--ds-radius-lg);
  border-bottom-right-radius: var(--ds-radius-lg);
  overflow: hidden;
}

/* ---------------------------------------------------------------- *
 * Controls
 * ---------------------------------------------------------------- */

.btn {
  border-radius: var(--ds-radius-sm);
  font-weight: 600;
}

.btn-sm {
  border-radius: 0.4rem;
}

.form-control,
.form-select {
  border-radius: var(--ds-radius-sm);
  border-color: #dbe3ee;
  color: var(--ds-ink);
}

.form-control:focus,
.form-select:focus {
  border-color: #9dc2e6;
  box-shadow: 0 0 0 0.2rem rgba(31, 109, 178, 0.14);
}

.form-control::placeholder {
  color: var(--ds-faint);
}

.form-label {
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ds-body);
}

.input-group-text {
  border-color: #dbe3ee;
  background: var(--ds-hover);
  color: var(--ds-muted);
}

/* ---------------------------------------------------------------- *
 * Modals
 * ---------------------------------------------------------------- */

.modal-content {
  border: 0;
  border-radius: var(--ds-radius-lg);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.modal-header {
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ds-line-soft);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ds-ink);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--ds-line-soft);
}

/* Bootstrap's footer adds its own margin to every child on top of the gap. */
.modal-footer > * {
  margin: 0;
}

/* The dialogs that render with `.show d-block` rather than through Bootstrap's
   own JS get their scrim here, since no `.modal-backdrop` fade applies to them
   until the element is in the DOM. */
.modal.show.d-block {
  background: rgba(15, 23, 42, 0.35);
}

@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-content {
    border-radius: 0;
  }
}

/* ---------------------------------------------------------------- *
 * Tabs
 *
 * The patient/consultation tab strip. Rendered as one segmented track for the
 * same reason the period picker is: it is a single choice.
 * ---------------------------------------------------------------- */

.ds-tabs {
  display: flex;
  gap: 0.15rem;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: var(--ds-line-soft);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.ds-tabs::-webkit-scrollbar {
  display: none;
}

.ds-tab {
  flex: 1 1 auto;
  padding: 0.45rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.ds-tab:hover {
  color: var(--ds-ink);
}

.ds-tab.is-active {
  background: #fff;
  color: var(--ds-primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

/* ---------------------------------------------------------------- *
 * Alerts
 * ---------------------------------------------------------------- */

.alert {
  border-radius: var(--ds-radius);
  border-width: 1px;
}

/* ---------------------------------------------------------------- *
 * Utilities
 * ---------------------------------------------------------------- */

.ds-muted-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

.ds-numeric {
  font-variant-numeric: tabular-nums;
}

.min-w-0 {
  min-width: 0;
}
