/* MDCare design foundation.
 *
 * Tokens first, taken from the brand kit: navy carries structure, teal is the
 * one accent (buttons, links, focus), and amber is reserved for attention -
 * which in this product means a maintenance overdue or a reading out of
 * limits, so it must never be spent on decoration. Type is the brand's own
 * system stack; nothing is fetched from a font CDN.
 *
 * Bootstrap stays underneath for layout and forms. Where it shows, these
 * variables restyle it rather than fighting it.
 */

:root {
  --md-navy: #0E2A47;
  --md-navy-deep: #0B1B2E;
  --md-teal: #0FA3A3;
  --md-teal-dark: #0B8484;
  --md-teal-soft: #E6F6F6;
  --md-amber: #F2A900;
  --md-amber-soft: #FFF4D6;
  --md-ink: #14212E;
  --md-slate: #5B6B7C;
  --md-slate-light: #A9B8C8;
  --md-line: #E1E7EE;
  --md-bg: #F4F7FA;
  --md-surface: #FFFFFF;
  --md-radius: 10px;
  --md-font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  /* Bootstrap 5.3 reads these, so its own components pick up the brand. */
  --bs-font-sans-serif: var(--md-font);
  --bs-body-color: var(--md-ink);
  --bs-body-bg: var(--md-bg);
  --bs-link-color: var(--md-teal-dark);
  --bs-link-hover-color: var(--md-navy);
  --bs-border-color: var(--md-line);
}

body {
  font-family: var(--md-font);
  color: var(--md-ink);
  background: var(--md-bg);
  -webkit-font-smoothing: antialiased;
}

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

.btn-primary {
  --bs-btn-bg: var(--md-teal);
  --bs-btn-border-color: var(--md-teal);
  --bs-btn-hover-bg: var(--md-teal-dark);
  --bs-btn-hover-border-color: var(--md-teal-dark);
  --bs-btn-active-bg: var(--md-teal-dark);
  --bs-btn-active-border-color: var(--md-teal-dark);
  --bs-btn-focus-shadow-rgb: 15, 163, 163;
  --bs-btn-font-weight: 600;
  --bs-btn-padding-y: .7rem;
  --bs-btn-border-radius: var(--md-radius);
}

.btn-outline-primary {
  --bs-btn-color: var(--md-teal-dark);
  --bs-btn-border-color: var(--md-teal);
  --bs-btn-hover-bg: var(--md-teal);
  --bs-btn-hover-border-color: var(--md-teal);
  --bs-btn-active-bg: var(--md-teal-dark);
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: var(--md-radius);
}

/* Forms --------------------------------------------------------------- */

.form-label {
  font-weight: 600;
  font-size: .875rem;
  color: var(--md-navy);
}

.form-control,
.form-select {
  border-color: var(--md-line);
  border-radius: var(--md-radius);
  padding: .65rem .85rem;
  color: var(--md-ink);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--md-teal);
  box-shadow: 0 0 0 .25rem rgba(15, 163, 163, .18);
}

.form-text { color: var(--md-slate); }

/* The authentication layout ----------------------------------------------
 * A brand panel and a form panel, side by side; stacked on a phone. Every
 * signed-out page - sign in, sign up, password reset, invitation - uses it,
 * so the first thing anyone sees of MDCare is the same thing.
 */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}

.auth-brand {
  background: var(--md-navy-deep);
  color: #fff;
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3rem;
  position: relative;
  overflow: hidden;
}

/* A faint echo of the logo's arc, so the panel is not a flat block. */
.auth-brand::after {
  content: "";
  position: absolute;
  right: -18rem;
  bottom: -18rem;
  width: 36rem;
  height: 36rem;
  border-radius: 50%;
  border: 3rem solid rgba(15, 163, 163, .10);
  pointer-events: none;
}

.auth-brand .logo { width: 220px; height: auto; display: block; }

.auth-brand h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 0 0 .9rem;
}

.auth-brand .lede {
  color: var(--md-slate-light);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 34rem;
  margin: 0 0 1.8rem;
}

.auth-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .85rem;
  max-width: 34rem;
}

.auth-points li {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  line-height: 1.5;
  color: #E6EDF4;
}

.auth-points svg {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: .15rem;
  color: var(--md-teal);
}

.auth-brand .brand-foot {
  font-size: .8125rem;
  color: var(--md-slate-light);
  position: relative;
}

.auth-brand .brand-foot a { color: #fff; text-decoration: none; }
.auth-brand .brand-foot a:hover { text-decoration: underline; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  background: var(--md-surface);
}

.auth-card { width: 100%; max-width: 26rem; }

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--md-navy);
  margin-bottom: .35rem;
}

.auth-card .intro { color: var(--md-slate); margin-bottom: 1.75rem; }

.auth-card .muted-note { color: var(--md-slate); font-size: .875rem; }

/* Only shown on a phone, where the brand panel collapses to a strip. */
.auth-mobile-logo { display: none; }

.auth-lang { position: absolute; top: 1.25rem; right: 1.5rem; }
.auth-lang .form-select {
  padding: .3rem 1.9rem .3rem .6rem;
  font-size: .8125rem;
  width: auto;
  border-radius: 8px;
}

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { align-items: flex-start; padding-top: 2.5rem; }
  .auth-mobile-logo { display: block; width: 180px; height: auto; margin: 0 auto 2rem; }
  .auth-lang { position: static; display: flex; justify-content: flex-end; margin-bottom: 1rem; }
}

/* The application shell -----------------------------------------------
 * Navigation carries the brand; content sits on the soft background.
 */

.md-navbar {
  --bs-navbar-color: rgba(255, 255, 255, .78);
  --bs-navbar-hover-color: #fff;
  --bs-navbar-active-color: #fff;
  background: var(--md-navy);
}

.md-navbar .navbar-brand img { height: 30px; width: auto; display: block; }

.md-navbar .dropdown-menu {
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  box-shadow: 0 8px 24px rgba(14, 42, 71, .12);
}

.md-navbar .form-control,
.md-navbar .form-select {
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.md-navbar .form-control::placeholder { color: rgba(255, 255, 255, .55); }

.md-navbar .form-control:focus {
  background: rgba(255, 255, 255, .14);
  border-color: var(--md-teal);
  color: #fff;
}

.md-navbar .btn-scan {
  --bs-btn-bg: var(--md-teal);
  --bs-btn-border-color: var(--md-teal);
  --bs-btn-hover-bg: var(--md-teal-dark);
  --bs-btn-hover-border-color: var(--md-teal-dark);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-font-weight: 600;
}

/* Page structure ---------------------------------------------------------
 * The shell owns vertical rhythm; pages own their content. A page that wants
 * the standard width uses .md-container; the dashboard and the settings
 * pages both do.
 */

.md-app { min-height: 100vh; display: flex; flex-direction: column; }
.md-page { flex: 1 0 auto; padding: 1.75rem 0 3rem; }
.md-container { width: 100%; max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }

.md-footer {
  border-top: 1px solid var(--md-line);
  padding: 1rem 0 1.25rem;
  font-size: .8125rem;
  color: var(--md-slate);
}
.md-footer a { color: var(--md-slate); text-decoration: none; }
.md-footer a:hover { color: var(--md-navy); text-decoration: underline; }

.md-alert { border-radius: var(--md-radius); }

/* Page header: a title, an optional line under it, actions to the right. */
.md-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  margin-bottom: 1.5rem;
}
.md-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--md-navy);
  margin: 0;
}
.md-header .sub { color: var(--md-slate); margin: .25rem 0 0; }
.md-header .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Section heading inside a page. */
.md-section-title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--md-slate);
  margin: 0 0 .75rem;
}

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

.md-card {
  background: var(--md-surface);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 1.25rem;
}

.md-card > .md-section-title:first-child { margin-top: -.15rem; }

/* Stat tile: the number is the point; the label explains it. */
.md-stat {
  background: var(--md-surface);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 1rem 1.15rem;
  height: 100%;
  border-top: 3px solid var(--md-line);
}
.md-stat .value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: var(--md-navy);
}
.md-stat .label { color: var(--md-slate); font-size: .875rem; margin-top: .2rem; }
.md-stat.is-good { border-top-color: var(--md-teal); }
.md-stat.is-warn { border-top-color: var(--md-amber); }
.md-stat.is-warn .value { color: #9A6B00; }
.md-stat.is-bad { border-top-color: var(--md-red); }
.md-stat.is-bad .value { color: var(--md-red); }

/* Attention list: a coloured rail says how bad, so the eye sorts it. */
.md-rows { display: flex; flex-direction: column; gap: .5rem; }
.md-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: var(--md-surface);
  border: 1px solid var(--md-line);
  border-left: 4px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: .8rem 1rem;
  color: var(--md-ink);
  text-decoration: none;
  transition: border-color .12s, box-shadow .12s;
}
.md-row:hover { color: var(--md-ink); border-color: var(--md-slate-light); box-shadow: 0 2px 10px rgba(14, 42, 71, .08); }
.md-row.is-danger { border-left-color: var(--md-red); }
.md-row.is-warning { border-left-color: var(--md-amber); }
.md-row .title { font-weight: 600; color: var(--md-navy); }
.md-row .detail { color: var(--md-slate); font-size: .875rem; margin-top: .15rem; }
.md-row .when { color: var(--md-slate); font-size: .8125rem; white-space: nowrap; padding-top: .15rem; }

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

.md-table { --bs-table-bg: transparent; margin-bottom: 0; }
.md-table > thead th {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--md-slate);
  border-bottom: 1px solid var(--md-line);
  padding: .5rem .75rem;
}
.md-table > tbody td { padding: .6rem .75rem; border-bottom: 1px solid var(--md-line); vertical-align: middle; }
.md-table > tbody tr:last-child td { border-bottom: 0; }
.md-table > tbody tr.md-group th {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--md-slate);
  background: var(--md-bg);
  padding: .4rem .75rem;
}

/* Meaning colours. Amber is attention, red is a limit crossed, teal is
 * fine. Bootstrap's own semantic classes are remapped so existing templates
 * inherit the palette without being rewritten.
 */

:root { --md-red: #B42318; --md-red-soft: #FDECEA; }

.badge.bg-warning, .badge.text-bg-warning { background-color: var(--md-amber) !important; color: #2B2000 !important; }
.badge.bg-danger,  .badge.text-bg-danger  { background-color: var(--md-red) !important; }
.badge.bg-success, .badge.text-bg-success { background-color: var(--md-teal) !important; }
.badge.bg-secondary { background-color: var(--md-slate) !important; }
.text-danger { color: var(--md-red) !important; }
.text-success { color: var(--md-teal-dark) !important; }
.alert-success { --bs-alert-bg: var(--md-teal-soft); --bs-alert-border-color: #BFE6E6; --bs-alert-color: #0B5E5E; }
.alert-warning { --bs-alert-bg: var(--md-amber-soft); --bs-alert-border-color: #F6DDA0; --bs-alert-color: #6B4A00; }
.alert-danger  { --bs-alert-bg: var(--md-red-soft);   --bs-alert-border-color: #F5C2BC; --bs-alert-color: #7A1A12; }

/* Settings sidebar (console) ------------------------------------------- */

.md-sidenav .list-group-item {
  border: 0;
  border-radius: 8px;
  color: var(--md-ink);
  background: transparent;
  padding: .55rem .8rem;
  margin-bottom: 2px;
}
.md-sidenav .list-group-item:hover { background: var(--md-surface); }
.md-sidenav .list-group-item.active {
  background: var(--md-teal-soft);
  color: var(--md-teal-dark);
  font-weight: 600;
}

/* Generic Bootstrap surfaces used by older pages, softened to the palette. */
.card { border-color: var(--md-line); border-radius: var(--md-radius); }
.list-group-item { border-color: var(--md-line); }
.btn-outline-secondary {
  --bs-btn-color: var(--md-navy);
  --bs-btn-border-color: var(--md-line);
  --bs-btn-hover-bg: var(--md-surface);
  --bs-btn-hover-color: var(--md-navy);
  --bs-btn-hover-border-color: var(--md-slate-light);
  --bs-btn-border-radius: var(--md-radius);
}
