/* =========================================================
   Theme — ported from Speechlytics (Overrides.css / Site.css).
   --tmf-primary and --tmf-secondary come from the branding template (_BrandTheme); every shade below is derived
   from them, so a template only sets two colours. Status colours (success, danger, warning) keep Bootstrap's
   defaults: their contrast is what keeps the pages at Lighthouse accessibility 100.
   ========================================================= */

:root {
  --tmf-primary: #63487b;
  --tmf-secondary: #27697a;
  --tmf-primary-hover: color-mix(in srgb, var(--tmf-primary) 83%, #000);
  --tmf-primary-active: color-mix(in srgb, var(--tmf-primary) 71%, #000);
  --tmf-primary-light: color-mix(in srgb, var(--tmf-primary) 75%, #fff);
  --tmf-primary-disabled: color-mix(in srgb, var(--tmf-primary) 45%, #fff);
  --tmf-primary-soft: color-mix(in srgb, var(--tmf-primary) 12%, transparent);
  --tmf-primary-tint: color-mix(in srgb, var(--tmf-primary) 10%, #fff);
  --tmf-primary-ring: color-mix(in srgb, var(--tmf-primary) 22%, transparent);
  --tmf-shadow: 0 6px 20px color-mix(in srgb, var(--tmf-primary) 8%, transparent);
  --tmf-topbar-height: 64px;
  --tmf-sidebar-width: 248px;
  --tmf-sidebar-collapsed-width: 72px;

  --bs-body-bg: #f7f6fa;
  --bs-body-color: #4a4a4a;
  --bs-border-color: #e1e1e8;
  --bs-link-color: var(--tmf-primary);
  --bs-link-hover-color: var(--tmf-primary-hover);
  --bs-focus-ring-color: var(--tmf-primary-ring);
  --bs-border-radius: 0.65rem;
  --bs-border-radius-sm: 0.5rem;
  --bs-border-radius-lg: 0.85rem;
}

body {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

a { color: var(--tmf-primary); }
a:hover, a:focus { color: var(--tmf-primary-hover); }

.text-primary { color: var(--tmf-primary) !important; }
.bg-primary, .text-bg-primary { background-color: var(--tmf-primary) !important; color: #fff !important; }
.border-primary { border-color: var(--tmf-primary) !important; }

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

.btn {
  border-radius: 0.7rem;
  font-weight: 500;
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.btn:focus-visible,
.btn-check:focus-visible + .btn { box-shadow: 0 0 0 0.25rem var(--tmf-primary-ring); }

.btn:not(.btn-sm):not(.btn-lg):not(.btn-link) {
  min-height: 42px;
  padding: 8px 14px;
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--tmf-primary);
  --bs-btn-border-color: var(--tmf-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--tmf-primary-hover);
  --bs-btn-hover-border-color: var(--tmf-primary-hover);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tmf-primary-active);
  --bs-btn-active-border-color: var(--tmf-primary-active);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--tmf-primary-disabled);
  --bs-btn-disabled-border-color: var(--tmf-primary-disabled);
}

/* Secondary inverts on hover: white face, brand-coloured text and border (Speechlytics). */
.btn-secondary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--tmf-primary);
  --bs-btn-border-color: var(--tmf-primary);
  --bs-btn-hover-color: var(--tmf-primary);
  --bs-btn-hover-bg: #fff;
  --bs-btn-hover-border-color: var(--tmf-primary);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tmf-primary-active);
  --bs-btn-active-border-color: var(--tmf-primary-active);
}

.btn-outline-primary,
.btn-outline-secondary {
  --bs-btn-color: var(--tmf-primary);
  --bs-btn-border-color: var(--tmf-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--tmf-primary);
  --bs-btn-hover-border-color: var(--tmf-primary);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--tmf-primary-hover);
  --bs-btn-active-border-color: var(--tmf-primary-hover);
  --bs-btn-disabled-color: var(--tmf-primary-disabled);
  --bs-btn-disabled-border-color: var(--tmf-primary-disabled);
}

.btn-outline-secondary { --bs-btn-border-color: var(--bs-border-color); }

.btn-link {
  --bs-btn-color: var(--tmf-primary);
  --bs-btn-hover-color: var(--tmf-primary-hover);
}

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

.form-control,
.form-select {
  border-color: var(--bs-border-color);
  border-radius: 0.65rem;
  color: var(--bs-body-color);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--tmf-primary-light);
  box-shadow: 0 0 0 0.2rem var(--tmf-primary-ring);
}

.form-check-input:checked {
  background-color: var(--tmf-primary);
  border-color: var(--tmf-primary);
}

.form-check-input:focus { box-shadow: 0 0 0 0.2rem var(--tmf-primary-ring); }

/* ---------- Cards, tables, lists ---------- */

.card {
  background-color: #fff;
  border-color: var(--bs-border-color);
  box-shadow: var(--tmf-shadow);
}

.card-header {
  background-color: var(--tmf-primary-tint);
  border-bottom: 1px solid var(--bs-border-color);
  color: #2b2b2b;
  font-weight: 600;
}

.table {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: #fff;
  --bs-table-border-color: var(--bs-border-color);
}

.table thead th {
  background-color: var(--tmf-primary-tint);
  color: #2b2b2b;
  border-bottom: 1px solid color-mix(in srgb, var(--tmf-primary) 18%, #fff);
}

.table-hover tbody tr:hover > * { --bs-table-bg-state: var(--tmf-primary-soft); }

.list-group-item-action:hover,
.list-group-item-action:focus,
.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--tmf-primary-soft);
  color: var(--tmf-primary);
}

.dropdown-item:active,
.dropdown-item.active {
  background-color: var(--tmf-primary);
  color: #fff;
}

.nav-tabs .nav-link,
.nav-pills .nav-link {
  color: var(--tmf-primary);
  font-weight: 600;
}

.nav-pills .nav-link.active { background-color: var(--tmf-primary); color: #fff; }

.pagination {
  --bs-pagination-color: var(--tmf-primary);
  --bs-pagination-hover-color: var(--tmf-primary-hover);
  --bs-pagination-focus-color: var(--tmf-primary-hover);
  --bs-pagination-focus-box-shadow: 0 0 0 0.2rem var(--tmf-primary-ring);
  --bs-pagination-active-bg: var(--tmf-primary);
  --bs-pagination-active-border-color: var(--tmf-primary);
}

/* ---------- Top bar and brand ---------- */

.tmf-topbar {
  min-height: var(--tmf-topbar-height);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--tmf-primary-soft);
  box-shadow: 0 8px 20px rgba(33, 29, 88, 0.05);
  backdrop-filter: blur(6px);
}

.tmf-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  max-width: 100%;
  color: var(--tmf-primary);
}

.tmf-brand:hover, .tmf-brand:focus { color: var(--tmf-primary-hover); }

.tmf-brand-logo {
  height: 46px;
  width: auto;
  flex-shrink: 0;
}

.tmf-brand-name {
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Phones: the bar has room for the logo only; the name stays as the link's accessible name. */
@media (max-width: 575.98px) {
  .tmf-brand-logo { height: 38px; }
  .tmf-brand-logo + .tmf-brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

/* ---------- Sidebar (collapsible on desktop, off-canvas on phones) ---------- */

.tmf-sidebar { background: #fff; }

.tmf-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2px 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  color: var(--bs-body-color);
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

.tmf-sidebar .nav-link > .bi {
  flex: 0 0 1.25rem;
  font-size: 1.1rem;
  text-align: center;
  opacity: 0.9;
}

.tmf-sidebar .nav-link:hover,
.tmf-sidebar .nav-link:focus {
  background: var(--tmf-primary-soft);
  color: var(--tmf-primary);
}

.tmf-sidebar .nav-link.active {
  background: var(--tmf-primary-soft);
  color: var(--tmf-primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--tmf-primary);
}

.tmf-nav-group {
  border-top: 1px solid var(--bs-border-color);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.tmf-sidebar-toggle {
  align-self: flex-end;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  margin: 0.5rem 0.75rem 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--tmf-primary);
  transition: background-color .15s ease;
}

.tmf-sidebar-toggle:hover,
.tmf-sidebar-toggle:focus-visible { background: var(--tmf-primary-soft); }

.tmf-sidebar-toggle .bi { transition: transform .2s ease; }

@media (min-width: 992px) {
  .tmf-sidebar {
    flex: 0 0 var(--tmf-sidebar-width);
    width: var(--tmf-sidebar-width);
    min-height: calc(100vh - var(--tmf-topbar-height));
    border-right: 1px solid var(--bs-border-color);
    overflow-x: hidden;
    transition: width .2s ease, flex-basis .2s ease;
  }

  .tmf-sidebar-collapsed .tmf-sidebar {
    flex-basis: var(--tmf-sidebar-collapsed-width);
    width: var(--tmf-sidebar-collapsed-width);
  }

  .tmf-sidebar-collapsed .tmf-sidebar-toggle { align-self: center; }
  .tmf-sidebar-collapsed .tmf-sidebar-toggle .bi { transform: rotate(180deg); }
  .tmf-sidebar-collapsed .tmf-sidebar .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }

  /* Hidden from sight, not from screen readers: the link keeps its name. */
  .tmf-sidebar-collapsed .tmf-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tmf-sidebar, .tmf-sidebar-toggle .bi, .tmf-sidebar .nav-link, .btn { transition: none; }
}

/* ---------- Page title (Speechlytics _PageTitle) ---------- */

h1.page-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 0 0 0.75rem;
  border-bottom: 2px solid var(--tmf-secondary);
  color: var(--tmf-secondary);
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.7rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1.page-title > .bi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  background: var(--tmf-primary-tint);
  color: var(--tmf-secondary);
  font-size: 1.15rem;
  box-shadow: 0 8px 18px rgba(33, 29, 88, 0.16);
  flex-shrink: 0;
}

.page-title-text { min-width: 0; overflow-wrap: anywhere; }

h1.page-title.text-center { justify-content: center; }

/* A title that shares its row with actions (New, filters…): the row carries the rule, the title does not. */
.d-flex:has(> h1.page-title) {
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--tmf-secondary);
  margin-bottom: 1.5rem !important;
}

.d-flex > h1.page-title {
  margin: 0;
  padding: 0;
  border: 0;
}

/* ---------- Sign-in pages ---------- */

.tmf-auth-main { max-width: 440px; }

.tmf-auth-logo {
  max-width: 220px;
  width: 60%;
  height: auto;
}

.tmf-auth-name {
  color: var(--tmf-primary);
  font-size: 1.15rem;
  font-weight: 600;
}

/* ---------- Existing helpers ---------- */

.tmf-tap { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; }

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

.tmf-narrow { max-width: 560px; }

.tmf-session-time { min-width: 3.25rem; }

/* Projector: the QR fills most of the screen and stays square. */
.tmf-projector { background: #fff; }
.tmf-qr { width: min(80vh, 90vw); aspect-ratio: 1; }
.tmf-qr svg { width: 100%; height: 100%; }

.tmf-code { letter-spacing: .25em; }

.tmf-stat { border-left: 4px solid var(--tmf-primary); }
