/* BNI Training Portal: same look as BNI Pulse (BNI red / granite / sterling grey, Arial, pill buttons, grey top menu). */
:root {
  --bni-red: #CF2030;
  --bni-red-dark: #951722;
  --bni-red-tint: #FAE8EA;
  --pm-blue: #2C5C99;
  --pm-blue-bg: #E3ECF7;
  --slot-open-bg: #EEEEEE;
  --slot-open-border: #8C8D8F;
  --slot-scheduled-bg: #E5F3EA;
  --slot-scheduled-border: #1F7A4D;
  --slot-unconfirmed-bg: #FBF0DE;
  --slot-unconfirmed-border: #B5730E;
  --other-bg: #E6E6E6;
  --other-border: #A8A9AB;
  --holiday-gold-bg: #FBF0DE;
  --holiday-gold-border: #B5730E;
  --ink: #3F4145;
  --muted: #7A7C80;
  --border: #E6E6E6;
  --bg: #F2F2F2;
  --card-bg: #FFFFFF;
  --granite: #64666A;
  --sterling: #C8C8C8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--bg);
  padding-top: 64px; /* fallback until JS measures the real fixed topbar height */
}

a { color: var(--bni-red-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top menu (same as Pulse) ---- */
.topbar {
  background: linear-gradient(180deg, #6B6D71, #585A5E);
  color: #fff;
  padding: 8px 32px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  border-bottom: 3px solid var(--bni-red);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  gap: 18px;
}
.topbar-row { display: flex; align-items: center; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-logo { height: 26px; width: auto; display: block; }
.login-logo { display: block; margin: 0 auto 1.1rem; max-height: 56px; width: auto; }
.login-heading { text-align: center; margin-bottom: 1.1rem; }
.login-heading h1 { margin: 0 0 0.3rem; }
.login-heading .subtitle { margin: 0; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; padding: 0 9px; border-radius: 4px;
  background: var(--bni-red); color: #fff; font-size: 0.85rem; font-weight: 800; letter-spacing: .04em; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.brand-text b { font-size: 15px; letter-spacing: .3px; }
.brand-text small { font-size: 10.5px; color: #E4E4E4; font-weight: 400; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.55);
  color: #fff;
  border-radius: 999px;
  font-size: 1.1rem;
  padding: 0.2rem 0.8rem;
  cursor: pointer;
}

.topbar nav {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}
.topbar nav > a, .nav-link.nav-dropdown-toggle {
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  opacity: 1;
}
.topbar nav > a:hover, .nav-link.nav-dropdown-toggle:hover, .nav-item.open .nav-dropdown-toggle { background: rgba(255,255,255,.16); text-decoration: none; }
.topbar nav > a.on, .nav-link.nav-dropdown-toggle.on {
  background: var(--bni-red); border-color: var(--bni-red-dark); box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.nav-item { position: relative; }
.nav-caret { font-size: 0.6em; opacity: 0.85; text-decoration: none !important; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0,0,0,0.22);
  padding: 0.35rem;
  min-width: 190px;
  z-index: 110;
  flex-direction: column;
}
.nav-item.open .nav-dropdown-menu { display: flex; }
/* ".topbar nav a" would otherwise turn dropdown links white-on-white */
.topbar .nav-dropdown-menu a {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar .nav-dropdown-menu a:hover { background: var(--bni-red-tint); color: var(--bni-red-dark); text-decoration: none; }
.nav-dropdown-menu-right { left: auto; right: 0; }

.nav-item-who { margin-left: auto; }
.who-toggle { font-size: 12.5px !important; font-weight: 400 !important; border-color: rgba(255,255,255,.55) !important; padding: 6px 13px !important; }
.who-name { font-weight: 700; }
.who-role { opacity: 0.9; white-space: nowrap; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.4rem 2rem 2rem; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

h1 { font-size: 1.45rem; font-weight: 600; margin: 0 0 0.25rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; }
.subtitle { color: var(--muted); margin: 0 0 1.25rem; }

.analytics-details summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.analytics-details summary::marker { color: var(--muted); }
.analytics-details[open] summary { margin-bottom: 0.25rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover td { background: #FAFAF9; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.badge-active { background: #E5F3EA; color: #1F7A4D; }
.badge-inactive { background: #EEEFEE; color: #7A7C80; }
.badge-master { background: var(--bni-red-tint); color: var(--bni-red-dark); }
.badge-trainer { background: var(--pm-blue-bg); color: var(--pm-blue); }
.badge-trainee { background: #FBF0DE; color: #B5730E; }
.badge-tier { background: #EEEFEE; color: #4B4D51; }

.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--bni-red);
  background: var(--bni-red);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--bni-red-dark); border-color: var(--bni-red-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--sterling); }
.btn-secondary:hover { background: #fff; border-color: var(--bni-red); color: var(--bni-red-dark); }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--bni-red-dark); font-weight: 700; cursor: pointer; padding: 0; font-size: 0.85rem; }
.btn-link:hover { text-decoration: underline; }

form.inline { display: inline; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.9rem; margin-bottom: 1rem; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #CFCFCF;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--bni-red); outline-offset: 1px; border-color: var(--bni-red); }
.field textarea { resize: vertical; min-height: 2.4rem; }

/* Shadow trainer picker (assign.php) */
.shadow-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.shadow-chip {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  font-weight: normal;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.shadow-chip:hover { border-color: var(--bni-red); }
.shadow-chip input[type="checkbox"] { flex-shrink: 0; margin: 0; accent-color: var(--bni-red); }
.shadow-chip-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.shadow-chip-name { font-size: 0.88rem; font-weight: 600; overflow-wrap: break-word; }
.shadow-chip-tier { font-size: 0.72rem; color: var(--muted); }
.shadow-chip.is-checked { background: var(--bni-red-tint); border-color: var(--bni-red); }

@media (max-width: 720px) {
  .shadow-picker { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

.flash { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-success { background: #E5F3EA; color: #1F7A4D; border: 1px solid #B6E2C7; }
.flash-error { background: #FAE8EA; color: #951722; border: 1px solid #F2B8BF; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-tile {
  flex: 1;
  min-width: 140px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--bni-red);
  border-radius: 12px;
  padding: 1rem 1.2rem;
}
.stat-tile .num { font-size: 1.6rem; font-weight: 700; }
.stat-tile .label { color: var(--muted); font-size: 0.82rem; }

/* Calendar */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; min-width: 640px; }
.cal-dow { text-align: center; font-size: 0.78rem; color: var(--muted); font-weight: 600; padding-bottom: 0.2rem; }
.cal-day {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 108px;
  padding: 0.3rem;
  background: #fff;
}
.cal-day.faded { opacity: 0.35; }
.cal-day.holiday { background: var(--holiday-gold-bg); border-color: var(--holiday-gold-border); }
.cal-day.today { border: 2px solid var(--bni-red); }
.cal-day .date-num { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.15rem; }
.cal-day .holiday-name { font-size: 0.68rem; color: #92400E; margin-bottom: 0.2rem; }
.cal-slot {
  display: block;
  border-radius: 5px;
  padding: 0.2rem 0.3rem;
  font-size: 0.7rem;
  margin-bottom: 0.15rem;
  line-height: 1.25;
}
.cal-slot.status-open { background: var(--slot-open-bg); border: 2px dashed var(--slot-open-border); color: var(--muted); font-weight: 500; }
.cal-slot.status-scheduled { background: var(--slot-scheduled-bg); border: 1px solid var(--slot-scheduled-border); }
.cal-slot.status-unconfirmed { background: var(--slot-unconfirmed-bg); border: 2px dotted var(--slot-unconfirmed-border); }
.cal-slot .slot-time { font-weight: 700; }
.cal-slot .slot-trainer { font-weight: 600; }
.cal-slot .slot-shadow-badge {
  display: inline-block;
  background: rgba(0, 0, 0, 0.09);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.05em 0.5em;
  font-size: 0.62rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
/* Shown next to the lead trainer's name in "By trainer"/"By location" color
   mode, where the slot's own color is already spoken for — the only other
   place this appears is the legend, as a small standalone key. */
.slot-unconfirmed-badge {
  display: inline-block;
  background: var(--slot-unconfirmed-border);
  color: #fff;
  border-radius: 999px;
  width: 1.1em;
  height: 1.1em;
  line-height: 1.1em;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  vertical-align: middle;
}
.cal-slot .slot-loc { color: var(--muted); font-size: 0.64rem; }

/* Small color-key swatches, e.g. the Open/Scheduled legend on /calendar */
.color-key { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.color-key .key-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.color-key .key-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

/* Back to top */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--bni-red);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 40;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--bni-red-dark); }

/* Responsive */
@media (max-width: 900px) {
  body { padding-top: 56px; }
  .topbar { padding: 8px 14px; flex-wrap: wrap; gap: 8px 12px; }
  .topbar-row { width: 100%; justify-content: space-between; }
  .nav-toggle { display: inline-block; }
  .brand-logo { height: 28px; }
  .topbar nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px 0 8px;
  }
  .topbar nav.nav-open { display: flex; }
  .topbar nav .nav-item-who { order: 99; margin-left: 0; }
  .topbar nav > a, .nav-link.nav-dropdown-toggle { width: 100%; justify-content: space-between; }

  /* Dropdowns become inline expanding sections in the stacked mobile menu. */
  .topbar nav .nav-item { width: 100%; display: flex; flex-direction: column; }
  .topbar nav .nav-dropdown-menu {
    position: static;
    margin-top: 4px;
    background: rgba(255,255,255,0.1);
    border: none;
    box-shadow: none;
    width: 100%;
  }
  .topbar nav .nav-dropdown-menu a { color: #fff; }
  .topbar nav .nav-dropdown-menu a:hover { background: rgba(255,255,255,0.15); color: #fff; }

  .container { padding: 1rem; }
  .card { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-row { gap: 0.6rem; }
  .stat-tile { min-width: 45%; }

  .back-to-top { right: 1rem; bottom: 1rem; width: 42px; height: 42px; }
}

/* Analysis — data-bar style horizontal breakdowns */
.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 42px; align-items: center; gap: 0.7rem; font-size: 0.85rem; }
.bar-label { text-align: right; color: var(--ink); overflow-wrap: break-word; }
.bar-track { display: flex; align-items: stretch; height: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.bar-seg { height: 100%; }
.bar-seg + .bar-seg { border-left: 2px solid var(--card-bg); }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.bar-legend { display: flex; gap: 1.1rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.6rem; }
.bar-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }

.meter { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-top: 0.6rem; }
.meter-fill { height: 100%; background: var(--bni-red); }

@media (max-width: 720px) {
  .bar-row { grid-template-columns: 96px 1fr 34px; gap: 0.4rem; font-size: 0.78rem; }
}

/* Printing (calendar + reports) */
@media print {
  .topbar, .back-to-top, .no-print, .flash { display: none !important; }
  body { padding-top: 0; background: #fff; }
  .container { max-width: 100%; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; margin-bottom: 0.6rem; }
  .cal-scroll { overflow: visible; }
  .cal-grid { min-width: 0; }
  .cal-day { min-height: 95px; break-inside: avoid; }
  .cal-slot { break-inside: avoid; }
  .cal-slot .slot-loc { color: #444; }
  a { color: inherit; text-decoration: none; }
  table { font-size: 0.8rem; }
  @page { size: landscape; margin: 10mm; }
}

/* Medium screens (laptops): keep the menu on one line (Nov 2026) */
@media (min-width: 901px) and (max-width: 1440px) {
  .topbar nav { flex-wrap: nowrap; gap: 2px; }
  .topbar nav > a, .nav-link.nav-dropdown-toggle { padding: 8px 11px; }
  .who-role { display: none; }
}
@media (min-width: 901px) and (max-width: 1120px) {
  .brand-text small { display: none; }
  .topbar nav > a, .nav-link.nav-dropdown-toggle { padding: 7px 8px; font-size: 13px; }
}
@media (min-width: 901px) and (max-width: 1040px) { .topbar .brand-text { display: none; } }

/* Cancelled training (Nov 2026) */
.cal-slot.status-cancelled { background:#F3F4F6; border:1px dashed #9CA3AF; color:#6B7280; }
.cal-slot .slot-cancelled { display:inline-block; font-size:.7rem; font-weight:700; color:#B91C1C; text-transform:uppercase; letter-spacing:.02em; }
