/* ClubMeet Hub theme - Toastmasters Brand Manual v2.0 colours and type, on top of Bootstrap 5.3.
 *
 * How it works (beginner notes):
 *  - Bootstrap 5.3 switches colour sets with <html data-bs-theme="light|dark">.
 *  - Below we set our own "tokens" (--tm-*) for each mode, then point Bootstrap's variables at them.
 *  - Brand colours: Loyal Blue #004165, True Maroon #772432, Cool Gray #A9B2B1,
 *    Happy Yellow #F2DF74; approved gradient partner Blissful Blue #006094; Fair Gray #F5F5F5.
 *  - Fonts are self-hosted (the security policy allows only local files).
 */

/* ---- Fonts: Montserrat (headings, stands in for Gotham) and Source Sans 3 (body) ---- */
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/Montserrat-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/static/fonts/SourceSans3-latin-wght.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

/* ---- Light mode tokens ---- */
:root,
[data-bs-theme="light"] {
  --tm-blue: #004165;
  --tm-blue-light: #006094;
  --tm-maroon: #772432;
  --tm-gray: #a9b2b1;
  --tm-yellow: #f2df74;

  --tm-page: #f5f5f5;          /* Fair Gray */
  --tm-surface: #ffffff;
  --tm-text: #1b2830;
  --tm-muted: #52606a;
  --tm-border: #d5dbda;
  --tm-heading: #004165;
  --tm-link: #004165;
  --tm-link-hover: #006094;
  --tm-primary: #004165;
  --tm-primary-hover: #006094;
  --tm-focus: #006094;
  --tm-th-bg: #e9eeee;
  --tm-signal-green: #1e7a46;
  --tm-signal-yellow: #d9a400;
  --tm-signal-red: #b3261e;
  --tm-chart-bar: #2a78b5;
  --tm-chart-trend: #772432;
}

/* ---- Dark mode tokens (same brand colours, lifted for contrast) ---- */
[data-bs-theme="dark"] {
  --tm-page: #0e1a22;
  --tm-surface: #15262f;
  --tm-text: #e8eef0;
  --tm-muted: #a9b2b1;         /* Cool Gray */
  --tm-border: #2b4150;
  --tm-heading: #ffffff;
  --tm-link: #8fc7ea;
  --tm-link-hover: #f2df74;    /* Happy Yellow */
  --tm-primary: #006094;       /* Blissful Blue */
  --tm-primary-hover: #0a77b3;
  --tm-focus: #f2df74;
  --tm-th-bg: #1d3340;
  --tm-signal-green: #3fb27a;
  --tm-signal-yellow: #f2c230;
  --tm-signal-red: #ef6b62;
  --tm-chart-bar: #3f93cc;
  --tm-chart-trend: #f2df74;
}

/* ---- Point Bootstrap at the tokens ---- */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-font-family: "Source Sans 3", "Segoe UI", Arial, sans-serif;
  --bs-body-font-size: 1.0625rem;
  --bs-body-bg: var(--tm-page);
  --bs-body-color: var(--tm-text);
  --bs-secondary-color: var(--tm-muted);
  --bs-border-color: var(--tm-border);
  --bs-link-color: var(--tm-link);
  --bs-link-hover-color: var(--tm-link-hover);
  --bs-border-radius: 0.5rem;
  --bs-border-radius-lg: 0.75rem;
}

body { background: var(--tm-page); color: var(--tm-text); }
a { color: var(--tm-link); }
a:hover { color: var(--tm-link-hover); }

/* ---- Headings: Montserrat ---- */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .navbar-brand {
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  color: var(--tm-heading);
  letter-spacing: -0.01em;
}
h1, .h1 {
  font-weight: 700;
  padding-bottom: 0.4rem;
  border-bottom: 4px solid var(--tm-maroon);   /* True Maroon accent under page titles */
  display: inline-block;
}
h2, .h2, h3, .h3 { font-weight: 600; }
.text-muted { color: var(--tm-muted) !important; }

/* ---- Top bar: approved Loyal Blue -> Blissful Blue gradient, white text in both modes ---- */
.tm-navbar {
  background: linear-gradient(90deg, var(--tm-blue), var(--tm-blue-light));
  border-bottom: 3px solid var(--tm-maroon);
}
.tm-navbar .navbar-brand { color: #fff; font-weight: 700; }
.tm-navbar .nav-link { color: rgba(255, 255, 255, 0.88); font-weight: 500; }
.tm-navbar .nav-link:hover,
.tm-navbar .nav-link:focus { color: var(--tm-yellow); }
.tm-navbar .btn { white-space: nowrap; }   /* keep names like "Admin Synthetic" on one line */
.tm-theme-toggle { min-width: 6.5rem; }

/* ---- "Info" messages and badges use the brand blue instead of Bootstrap's cyan ---- */
[data-bs-theme="light"] {
  --bs-info-bg-subtle: #e3eef5;
  --bs-info-border-subtle: #b6d1e2;
  --bs-info-text-emphasis: #00304b;
}
[data-bs-theme="dark"] {
  --bs-info-bg-subtle: #10303f;
  --bs-info-border-subtle: #1f5273;
  --bs-info-text-emphasis: #a9d3ee;
}
.text-bg-info { background-color: var(--tm-blue-light) !important; color: #fff !important; }

/* ---- Cards and tables ---- */
.card {
  --bs-card-bg: var(--tm-surface);
  --bs-card-border-color: var(--tm-border);
  --bs-card-cap-bg: var(--tm-th-bg);
  margin-bottom: 1rem;
  border-radius: var(--bs-border-radius-lg);
}
.card-header { font-family: "Montserrat", "Segoe UI", Arial, sans-serif; font-weight: 600; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--tm-text); }
.table > thead > tr > th {
  background: var(--tm-th-bg);
  color: var(--tm-heading);
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom-color: var(--tm-border);
}
.form-control, .form-select {
  background-color: var(--tm-surface);
  color: var(--tm-text);
  border-color: var(--tm-border);
}

/* ---- Buttons ---- */
.btn { font-weight: 600; }
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--tm-primary);
  --bs-btn-border-color: var(--tm-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--tm-primary-hover);
  --bs-btn-hover-border-color: var(--tm-primary-hover);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tm-primary-hover);
  --bs-btn-active-border-color: var(--tm-primary-hover);
  --bs-btn-disabled-bg: var(--tm-primary);
  --bs-btn-disabled-border-color: var(--tm-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--tm-link);
  --bs-btn-border-color: var(--tm-link);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--tm-primary);
  --bs-btn-hover-border-color: var(--tm-primary);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tm-primary-hover);
  --bs-btn-active-border-color: var(--tm-primary-hover);
}
.bg-primary { background-color: var(--tm-primary) !important; }
.text-primary { color: var(--tm-link) !important; }

/* Clear keyboard focus in both modes. */
:focus-visible {
  outline: 3px solid var(--tm-focus);
  outline-offset: 2px;
}

/* ---- Existing component rules (kept from the first version) ---- */
.stat { font-family: "Montserrat", "Segoe UI", Arial, sans-serif; font-size: 1.8rem; font-weight: 700; }
.code-box { font-family: monospace; font-size: 2rem; letter-spacing: 0.15rem; }
.table td, .table th { vertical-align: middle; }
.qr { max-width: 320px; width: 100%; background: #fff; padding: 0.5rem; border-radius: 0.5rem; }
.logo { max-height: 72px; max-width: 160px; }
.signal-green { border-left: 8px solid var(--tm-signal-green); }
.signal-yellow { border-left: 8px solid var(--tm-signal-yellow); }
.signal-red { border-left: 8px solid var(--tm-signal-red); }
.pre-line { white-space: pre-line; }

/* ---- Printing: always black on white, whichever mode is on screen ---- */
@media print {
  .no-print { display: none !important; }
  :root, [data-bs-theme="dark"], [data-bs-theme="light"] {
    --tm-page: #fff; --tm-surface: #fff; --tm-text: #000; --tm-muted: #333;
    --tm-heading: #000; --tm-link: #000; --tm-border: #999; --tm-th-bg: #eee;
  }
}

/* Attendance trend chart (reports page). Colours differ per theme; the trend line is
   also dashed so it never relies on colour alone. */
.tm-chart-scroll { overflow-x: auto; }
.tm-chart { width: 100%; min-width: 32rem; height: auto; }
.tm-grid { stroke: var(--tm-border); stroke-width: 1; }
.tm-axis { fill: var(--tm-muted); font-size: 10px; }
.tm-bar { fill: var(--tm-chart-bar); }
.tm-bar:hover { opacity: 0.75; }
.tm-trend { fill: none; stroke: var(--tm-chart-trend); stroke-width: 2; stroke-dasharray: 6 4; }
.tm-key { display: inline-block; width: 1.4rem; vertical-align: middle; }
.tm-key-bar { height: 0.8rem; background: var(--tm-chart-bar); }
.tm-key-trend { border-top: 2px dashed var(--tm-chart-trend); }

/* Club calendar month grid: seven equal columns that also fit a phone. */
.tm-calendar { table-layout: fixed; }
.tm-calendar th, .tm-calendar td { padding: 0.25rem; text-align: left; vertical-align: top; }
.tm-calendar td { height: 4.5rem; }
.tm-other-month > * { opacity: 0.55; }
.tm-calendar td.tm-today { box-shadow: inset 0 0 0 2px var(--tm-focus); }
.tm-chip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px; text-align: left; text-decoration: none; }

/* Member faces: a small round photo (or initials) in front of each name. */
.tm-person { display: inline-flex; align-items: center; gap: 0.4rem; vertical-align: middle; }
.tm-face { width: 2rem; height: 2rem; flex: 0 0 2rem; border-radius: 50%; object-fit: cover; }
.tm-initials { display: inline-flex; align-items: center; justify-content: center;
  background: var(--tm-th-bg); color: var(--tm-text); border: 1px solid var(--tm-border);
  font-size: 0.75rem; font-weight: 600; }
.tm-initials::before { content: attr(data-initials); }
.tm-face-large { width: 100%; max-width: 10rem; height: auto; aspect-ratio: 1; border-radius: 50%;
  object-fit: cover; }
.badge .tm-face { width: 1.25rem; height: 1.25rem; flex-basis: 1.25rem; font-size: 0.55rem; }
/* Long names with a face must wrap inside their badge on a phone. */
.badge:has(.tm-person) { white-space: normal; text-align: left; }

/* On a phone, wide tables with forms in them become one block per row. */
@media (max-width: 575.98px) {
  .tm-stack, .tm-stack > tbody, .tm-stack tr, .tm-stack td { display: block; width: 100%; }
  .tm-stack tr:has(th) { display: none; }
  .tm-stack tr { padding: 0.5rem 0; border-bottom: 1px solid var(--tm-border); }
  .tm-stack > tbody > tr > td { border: 0; padding: 0.2rem 0.75rem; }
  .tm-stack > tbody > tr > td:first-child:not([colspan]) { font-weight: 600; }
}
@media (max-width: 575.98px) { .tm-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--tm-muted); } }
