/* ============================================================
   MYIPPON — Global Stylesheet
   
   WHY CSS VARIABLES (the :root section):
   We define colours and sizes ONCE at the top.
   Change --accent from yellow to blue and the ENTIRE
   platform updates — every button, border, highlight.
   No hunting through hundreds of lines of code.
   This is called a Design System.
   
   HOW THIS FILE IS ORGANISED:
   1. Variables (design tokens)
   2. Reset (remove browser defaults)
   3. Layout (sidebar + topbar structure)
   4. Components (buttons, cards, tables etc)
   5. Page-specific styles (login, profile etc)
   6. Animations
   7. Responsive (mobile adjustments)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
/* WHY: Define once, use everywhere. Change here = change everywhere */
/* WHY: Base variables that never change regardless of theme */
:root {
  --accent:      #f5c400;
  --accent-dim:  #c8960c;
  --accent-glow: rgba(245,196,0,0.12);
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --nav-w:       240px;
  --topbar-h:    72px;
  --radius:      6px;
  --radius-lg:   10px;
  --radius-xl:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --transition:  0.18s ease;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  /* WHY: Default dark theme values (overridden by [data-theme]) */
  --bg:     #0a0a0a;
  --bg2:    #111111;
  --bg3:    #1a1a1a;
  --bg4:    #222222;
  --border: #2a2a2a;
  --border2:#333333;
  --text:        #f0f0f0;
  --text-muted:  #888888;
  --text-dim:    #555555;
}

/* WHY: Dark theme — explicit override matching default */
[data-theme="dark"] {
  --bg:     #0a0a0a;
  --bg2:    #111111;
  --bg3:    #1a1a1a;
  --bg4:    #222222;
  --border: #2a2a2a;
  --border2:#333333;
  --text:        #f0f0f0;
  --text-muted:  #888888;
  --text-dim:    #555555;
}

/* WHY: Grey theme — charcoal, keeps yellow accent */
[data-theme="grey"] {
  --bg:     #2a2a2a;
  --bg2:    #333333;
  --bg3:    #3d3d3d;
  --bg4:    #474747;
  --border: #555555;
  --border2:#666666;
  --text:        #f0f0f0;
  --text-muted:  #aaaaaa;
  --text-dim:    #777777;
}

/* WHY: Light theme — white/light grey, keeps yellow accent */
[data-theme="light"] {
  --bg:     #f0f0f0;
  --bg2:    #ffffff;
  --bg3:    #e8e8e8;
  --bg4:    #d8d8d8;
  --border: #cccccc;
  --border2:#bbbbbb;
  --text:        #111111;
  --text-muted:  #555555;
  --text-dim:    #999999;
}

/* ── Reset ────────────────────────────────────────────────── */
/* WHY: Browsers have different default styles.
   Reset removes them so our styles are consistent everywhere */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased; /* smoother text on Mac */
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); cursor: pointer; }

/* ── Custom scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

/* ============================================================
   LAYOUT
   WHY CSS Grid: lets us define the entire page structure
   in one place — topbar spans full width, sidebar is fixed
   width, main content takes remaining space automatically
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1; /* span full width — both columns */
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: sticky; top: 0; /* stays at top when scrolling */
  z-index: 100; /* above all other content */
}
.topbar-logo {
  width: var(--nav-w);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%; flex-shrink: 0;
  overflow: hidden;
}
/* WHY (found 2026-09-04, real root cause of "logo squished/text vanished
   after making it bigger"): this box's width only ever makes sense as
   "match the sidebar's width" when a sidebar is actually visible next to
   it (Left/Top nav modes). In Cards/Hidden mode there IS no sidebar to
   align with, yet this box stayed pinned to that same fixed width anyway
   - fine with a small logo, but bumping the logo size left negative room
   for "MYIPPON" + the org name, and they were being clipped to nothing by
   this element's own overflow:hidden rather than showing an ellipsis.
   Freeing the width here (any time nav-hidden is active, not just at
   narrow window widths) lets the box size itself to its real content. */
body.nav-hidden .topbar-logo { width: auto; max-width: 340px; }
.topbar-logo-badge {
  width: 30px; height: 30px;
  background: var(--accent); border-radius: 8px;
  box-shadow: 0 2px 8px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 16px; color: #111;
  flex-shrink: 0;
}
/* WHY a flex-column wrapper, not two siblings side by side (2026-09-04,
   "the text for the dojo name needs to be in two rows not one as it is
   cut off"): with a bigger logo there wasn't enough width left on one
   row for a long org name to ever fully show, even with truncation -
   stacking "MYIPPON" above the org name, and letting the org name itself
   wrap onto up to two lines, uses the topbar's height instead of fighting
   for the same horizontal row. */
.topbar-logo-textblock { display: flex; flex-direction: column; justify-content: center; min-width: 0; overflow: hidden; }
.topbar-logo-text { line-height: 1.1; flex-shrink: 0; }
.topbar-logo-name { font-family: var(--font-display); font-size: 15px; color: var(--accent); letter-spacing: 1px; }
/* WHY -webkit-line-clamp:2, not white-space:nowrap+ellipsis (found
   2026-09-04, real root cause of "squished top-left text" seen all
   session - independent of nav mode): a single line could never fit a
   long org name like "Northern Karate Schools Richmond Hill" no matter
   how it was truncated. Line-clamp shows up to 2 full lines and only
   ellipsizes if it's STILL too long after that - the standard,
   universally-supported (all modern browsers, despite the vendor
   prefix) way to do multi-line clamping. min-width:0 stays required so
   this flex child can actually shrink to the space clamp needs to work with. */
.topbar-logo-sub  { font-size: 9px; color: var(--text-dim); letter-spacing: 1.5px; text-transform: uppercase; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; line-height: 1.4; margin-top: 2px; }

/* WHY min-width:0 (fixed 2026-09-03, "squished search and text"): a flex
   item's default min-width is auto (content size), not 0 - without this,
   topbar-center refused to shrink below the search input's natural width
   on medium windows, so it fought topbar-right for space instead of
   yielding it, squeezing/overlapping the credits+org+theme+avatar cluster. */
.topbar-center { flex: 1; min-width: 0; }
/* Search bar in topbar */
.topbar-search { flex: 1; padding: 0 20px; position: relative; min-width: 0; }
.topbar-search input {
  width: 100%; max-width: 400px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text);
  padding: 7px 14px 7px 36px; font-size: 13px;
  transition: var(--transition), box-shadow var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.topbar-search input::placeholder { color: var(--text-dim); }
.topbar-search-icon {
  position: absolute; left: 32px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim); font-size: 14px; pointer-events: none;
}

/* Search results dropdown */
.search-results {
  position: absolute; top: calc(100% + 4px); left: 20px;
  width: 100%; max-width: 400px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 200; display: none; overflow: hidden;
}
.search-results.open { display: block; }
.search-result-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg4); }
.search-result-name { font-size: 13px; color: var(--text); font-weight: 500; }
.search-result-belt { font-size: 11px; color: var(--text-muted); }

/* WHY flex-shrink:0 + min-width:0 on the search area (fixed 2026-09-03,
   "squished search and text"): topbar-right's pills (credits, org name)
   had no flex-shrink guard, so on medium window widths the flex layout
   let them compress/overlap instead of letting the search bar (the thing
   that should actually shrink first) give up space. topbar-org also had
   no length cap, so a long dojo name pushed everything else out of room. */
.topbar-right { display: flex; align-items: center; gap: 12px; padding-right: 20px; flex-shrink: 0; }
.topbar-add-student-btn {
  flex-shrink: 0; white-space: nowrap; font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: 20px; border: none; cursor: pointer;
  background: var(--accent); color: #111;
  transition: transform var(--transition), box-shadow var(--transition);
}
.topbar-add-student-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.topbar-usage { flex-shrink: 0; white-space: nowrap; }
.topbar-org {
  font-size: 11px; color: var(--text-muted);
  padding: 4px 12px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 20px;
  flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #111;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.topbar-avatar:hover { transform: scale(1.06); box-shadow: 0 4px 14px var(--accent-glow); }

/* User menu dropdown */
.user-menu-wrap { position: relative; display: flex; align-items: center; }
.user-menu {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 220px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.35));
  z-index: 300; overflow: hidden;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
.user-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-menu-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.user-menu-header-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-menu-header-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13px; color: var(--text);
  text-decoration: none; cursor: pointer;
  transition: background var(--transition);
}
.user-menu-item:hover { background: var(--bg4); }
.user-menu-item-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-menu-item.danger { color: #ef4444; }
.user-menu-caret {
  font-size: 9px; color: var(--text-muted); margin-left: -4px;
  transition: transform var(--transition);
}
.user-menu-caret.open { transform: rotate(180deg); }
.topbar-logout {
  font-size: 12px; color: var(--text-muted);
  background: none; border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--radius-lg);
  transition: var(--transition);
}
.topbar-logout:hover { color: var(--text); border-color: var(--text-muted); background: var(--bg3); }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px 0; overflow-y: auto;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); /* full height minus topbar */
}
/* Nav position modes */
.sidebar.nav-top {
  position: fixed !important; top: var(--topbar-h) !important;
  left: 0 !important; right: 0 !important; width: 100% !important;
  height: 48px !important; min-height: 48px !important;
  flex-direction: row !important; overflow-x: auto !important; overflow-y: hidden !important;
  display: flex !important; align-items: center !important;
  gap: 2px !important; padding: 0 12px !important;
  border-right: none !important; border-bottom: 1px solid var(--border) !important;
  z-index: 90 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}
.sidebar.nav-top .sidebar-section-label,
.sidebar.nav-top .sidebar-logo { display: none !important; }
.sidebar.nav-top .sidebar-section { display: contents !important; margin: 0 !important; }
.sidebar.nav-top .sidebar-link {
  display: inline-flex !important; align-items: center !important;
  gap: 5px !important; padding: 5px 10px !important;
  border-radius: 6px !important; white-space: nowrap !important;
  font-size: 12px !important; height: 36px !important;
}
.nav-top-spacer { height: 48px; display: none; }
.sidebar.nav-top ~ * .nav-top-spacer,
body.nav-top .nav-top-spacer { display: block; }
.main-content.nav-top { margin-left: 0 !important; padding-top: 48px !important; }
.sidebar.nav-hidden { display: none !important; }
.main-content.nav-hidden { margin-left: 0 !important; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-label {
  font-size: 9px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.5px;
  padding: 12px 20px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  margin: 1px 8px; padding: 9px 12px; color: var(--text-muted); font-size: 13px;
  border-left: 2px solid transparent; border-radius: var(--radius);
  transition: var(--transition); cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover { color: var(--text); background: var(--bg3); }
/* Active link gets yellow left border and yellow text */
.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}
.sidebar-link-icon { width: 16px; text-align: center; font-size: 14px; }

/* Collapsible sidebar group (2026-09-06, "reports section on the left
   panel and then a dropdown menu from there" - groups Financial
   Reports/Renewals/Daily Report under one "Reports" parent instead of
   three flat top-level links). The chevron rotates via the .open class,
   which JS also uses to show/hide .sidebar-submenu - no separate icon
   swap needed. */
.sidebar-group-toggle { justify-content: space-between; }
.sidebar-group-chevron { transition: var(--transition); font-size: 10px; color: var(--text-dim); }
.sidebar-group-toggle.open .sidebar-group-chevron { transform: rotate(90deg); }
.sidebar-submenu { max-height: 0; overflow: hidden; }
.sidebar-submenu.open { max-height: 300px; }
.sidebar-submenu .sidebar-link { margin-left: 22px; }

/* ── Main content area ────────────────────────────────────── */
.main-content { padding: 24px; overflow-y: auto; }

/* ============================================================
   COMPONENTS
   Reusable UI pieces used across multiple pages
   ============================================================ */

/* ── Page header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-family: var(--font-display); font-size: 30px;
  color: var(--text); letter-spacing: 1.2px;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
/* WHY a class, not inline style.display (2026-09-13, generic page-layout
   drag-and-drop engine in nav.js): several pages conditionally show/hide a
   card themselves via inline style.display based on real data state (e.g.
   renewals.html's pending-renewal-requests-card only appears when there
   ARE pending requests) - the layout engine setting style.display directly
   would fight that logic every time it re-applies. A dedicated class the
   engine owns exclusively never touches or gets touched by a page's own
   inline style, so "hidden via Customize Layout" and "hidden because
   there's no data right now" can coexist without one silently undoing
   the other. */
.page-layout-hidden { display: none !important; }

.stat-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border2); box-shadow: var(--shadow); transform: translateY(-2px); }
/* Yellow line appears on top of card on hover */
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--accent);
  opacity: 0; transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }
.stat-card-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.stat-card-value {
  font-family: var(--font-display); font-size: 36px;
  color: var(--accent); letter-spacing: 1px; line-height: 1;
}
.stat-card-sub { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500; border: none;
  cursor: pointer; transition: transform 0.12s ease, box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-accent  { background: var(--accent); color: #111; box-shadow: 0 2px 10px var(--accent-glow); }
.btn-accent:hover { background: var(--accent-dim); box-shadow: 0 4px 16px var(--accent-glow); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.btn-ghost   { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-danger  { background: var(--danger); color: #fff; box-shadow: 0 2px 10px rgba(239,68,68,0.18); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Form elements ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent); background: var(--bg4);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-select { appearance: none; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
/* Two columns side by side */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Table ── */
.table-wrap {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* 2026-11-01 iPad upright (side menu showing): wide tables scroll inside their box instead of being cut off */
.table-wrap { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
@media (min-width: 1025px) and (max-width: 1180px) {
  .table-wrap th, .table-wrap td { padding-left: 8px; padding-right: 8px; }
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-search {
  background: var(--bg4); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font-size: 13px; min-width: 220px;
  transition: var(--transition);
}
.table-search:focus { outline: none; border-color: var(--accent); }
.table-filter {
  background: var(--bg4); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font-size: 13px; appearance: none; cursor: pointer;
}
.table-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg4); }
th {
  padding: 10px 14px; font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 500; text-align: left; white-space: nowrap;
}
td {
  padding: 11px 14px; font-size: 13px; color: var(--text);
  border-top: 1px solid var(--border); vertical-align: middle;
}
tr:hover td { background: var(--bg4); }
tr { cursor: pointer; transition: background var(--transition); }

/* ── Belt badge ── */
.belt-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 4px 10px;
  border-radius: 20px; background: var(--bg4);
  border: 1px solid var(--border); white-space: nowrap;
}
.belt-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Status badge ── */
.status-badge {
  display: inline-block; font-size: 10px; padding: 3px 10px;
  border-radius: 20px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.status-active   { background: rgba(34,197,94,0.15);  color: var(--success); }
.status-former   { background: rgba(239,68,68,0.15);  color: var(--danger); }
.status-inactive { background: rgba(107,114,128,0.15); color: var(--text-muted); }

/* ── Card ── */
.card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border2);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-family: var(--font-display); font-size: 18px; letter-spacing: 1px; }

/* ── Profile header ── */
.profile-header {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 26px;
  display: flex; gap: 20px; align-items: flex-start;
  margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 4px 16px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 28px; color: #111;
  flex-shrink: 0;
}
.profile-name {
  font-family: var(--font-display); font-size: 28px;
  letter-spacing: 1px; line-height: 1; margin-bottom: 6px;
}
.profile-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.profile-meta-item { font-size: 12px; color: var(--text-muted); }

/* ── Timeline (rank history) ── */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.timeline-content { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--text); }
.timeline-date  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.timeline-stripes { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.stripe-pill {
  font-size: 10px; padding: 1px 7px;
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-muted);
}

/* ── Loading states ── */
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}
/* Skeleton loader — pulsing grey bar shown while content loads */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon {
  font-size: 30px; margin: 0 auto 14px; opacity: 0.6;
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 50%; border: 1px solid var(--border);
}
.empty-state-text { font-size: 14px; }

/* ── Toast notification ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 18px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 9999;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.2s ease; max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(2px);
  z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px; box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-family: var(--font-display); font-size: 22px; letter-spacing: 1px; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; padding: 4px;
  border-radius: var(--radius); transition: var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ── Tabs ── */
.tabs {
  display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.tab {
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  color: var(--text); opacity: 0.55; border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: var(--transition);
  background: none; border-top: none; border-left: none; border-right: none;
  letter-spacing: 0.3px;
}
.tab:hover { opacity: 0.85; color: var(--text); background: var(--bg3); }
.tab.active { opacity: 1; color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; background: var(--accent-glow); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: none;
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 12px; cursor: pointer; transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #111; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(245,196,0,0.04) 0%, transparent 60%),
    repeating-linear-gradient(45deg, rgba(245,196,0,0.01) 0, rgba(245,196,0,0.01) 1px, transparent 1px, transparent 40px);
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-xl); padding: 40px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-badge {
  width: 56px; height: 56px; background: var(--accent);
  border-radius: 14px; box-shadow: 0 6px 20px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 28px; color: #111;
  margin: 0 auto 12px;
}
.login-logo-name { font-family: var(--font-display); font-size: 24px; color: var(--accent); letter-spacing: 2px; }
.login-logo-sub  { font-size: 10px; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; margin-top: 3px; }
.login-error {
  background: rgba(239,68,68,0.1); border: 1px solid var(--danger);
  color: #f87171; border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px; display: none;
}
.login-btn {
  width: 100%; background: var(--accent); color: #111;
  border: none; border-radius: var(--radius-lg); padding: 12px;
  font-size: 14px; font-weight: 500;
  font-family: var(--font-display); letter-spacing: 1px;
  cursor: pointer; transition: transform 0.12s ease, box-shadow var(--transition), background var(--transition);
  margin-top: 8px; box-shadow: 0 2px 12px var(--accent-glow);
}
.login-btn:hover { background: var(--accent-dim); box-shadow: 0 4px 20px var(--accent-glow); transform: translateY(-1px); }
.login-btn:active { transform: translateY(1px); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   WHY: Platform should work on tablets too - most iPads/Android
   tablets fall in the 768-1024px width range, where the fixed
   240px sidebar has nowhere to go. Below this breakpoint the
   sidebar is hidden by default and opened via a hamburger button
   that nav.js injects automatically (see applyNavPosition), reusing
   the same "hidden nav" mode already built for desktop users - so
   there is always a way back to navigation, never a dead end.
   ============================================================ */
/* WHY this breakpoint (added 2026-09-03, "squished search and text"): the
   org-name pill duplicates the sidebar logo's subtitle - dropping it first
   at medium widths (before anything else has to shrink/hide) gives the
   search bar and the credits/add-student/avatar cluster room to breathe
   without any of them ever needing to overlap. */
@media (max-width: 1400px) {
  .topbar-org { display: none; }
}
@media (max-width: 1024px) {
  .app-layout { grid-template-columns: 1fr; }
  .topbar-logo { width: auto; }
  .topbar-search { display: none; } /* WHY: no room next to hamburger + logo at this width */
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; } /* WHY: scrolls horizontally instead of crushing columns unreadably thin */
  .modal { padding: 20px; max-width: calc(100vw - 32px); }

  /* WHY these size bumps exist (2026-08-26, "manage 100% from a tablet
     without the need of a PC"): .btn-sm in particular is used for every
     row action (Pay Now, Refund, Send Invoice, Move Forward...) across
     student.html/billing.html/platform-admin.html, at ~26px tall on
     desktop - well under the ~44px touch target Apple/Google both
     recommend. A staff member tapping "Refund" next to "Cancel Invoice"
     on a real tablet is exactly the mis-tap scenario a martial-arts
     school full of parents and kids can't afford. Scoped to this
     breakpoint only, so desktop's denser layout is untouched. */
  .btn, .btn-sm { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .sidebar-link { min-height: 44px; }
  .form-input, .form-select, .form-textarea { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  #hamburger-btn { min-height: 44px; min-width: 44px; }
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
}

/* WHY a second, narrower tier (added 2026-09-04, "fit to window when I go
   full screen or half, quarter etc"): the 1024px tablet breakpoint above
   covers real tablets fine, but forcing exactly 2 stat-card columns there
   stops helping once a window gets genuinely narrow - a quarter-screen
   slice of a desktop monitor (roughly 400-480px) still only got 2 columns
   from that rule, each one cramped. This drops to a single column and
   tightens spacing further at that width, without touching anything
   above it. */
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }
  .page-title { font-size: 24px; }
  .modal { max-width: calc(100vw - 16px); margin: 8px; }
  .card { padding: 14px; }
}

/* ── Profile dropdown ── */
.profile-menu {
  position:absolute; top:calc(100% + 8px); right:0;
  background:var(--bg2); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow);
  min-width:200px; z-index:500; display:none; overflow:hidden;
}
.profile-menu.open { display:block; }
.profile-menu-header { padding:14px 16px; background:var(--bg3); }
.profile-menu-divider { height:1px; background:var(--border); }
.profile-menu-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 16px; font-size:13px; color:var(--text-muted);
  cursor:pointer; transition:var(--transition); text-decoration:none;
}
.profile-menu-item:hover { background:var(--bg3); color:var(--text); }
.profile-menu-item.danger:hover { color:var(--danger); }

/* ── Nav Position Modes ─────────────────────────────────── */
body.nav-top, body.nav-hidden { --nav-w: 0px; }
body.nav-top .app-layout  { grid-template-columns: 1fr !important; }
body.nav-top .sidebar {
  position: fixed !important; top: var(--topbar-h) !important;
  left: 0 !important; right: 0 !important; width: 100% !important;
  height: 48px !important; flex-direction: row !important;
  overflow-x: auto !important; overflow-y: hidden !important;
  display: flex !important; align-items: center !important;
  padding: 0 8px !important; gap: 0 !important;
  border-right: none !important; border-bottom: 1px solid var(--border) !important;
  z-index: 90 !important;
}
body.nav-top .sidebar-section { display: contents !important; margin: 0 !important; }
body.nav-top .sidebar-section-label { display: none !important; }
body.nav-top .sidebar-logo { display: none !important; }
body.nav-top .sidebar-link {
  display: inline-flex !important; align-items: center !important;
  gap: 4px !important; padding: 4px 8px !important;
  white-space: nowrap !important; font-size: 11px !important;
  height: 36px !important; border-radius: 6px !important;
}
body.nav-top .main-content { margin-left: 0 !important; padding-top: 72px !important; }
body.nav-hidden .app-layout { grid-template-columns: 1fr !important; }
body.nav-hidden .sidebar { display: none !important; }
body.nav-hidden .main-content { margin-left: 0 !important; }

/* Nav position — body-level overrides (driven by JS on document.body) */
body.nav-top .sidebar {
  position: fixed !important;
  top: var(--topbar-h) !important;
  left: 0; right: 0;
  height: 48px !important;
  flex-direction: row !important;
  overflow-x: auto; overflow-y: hidden;
  width: 100% !important;
  min-width: unset !important;
  z-index: 100;
  border-right: none !important;
  border-bottom: 1px solid var(--border);
}
body.nav-top .sidebar .sidebar-section-label,
body.nav-top .sidebar .sidebar-logo { display: none !important; }
body.nav-top .sidebar .sidebar-section { display: contents !important; margin: 0 !important; }
body.nav-top .sidebar .sidebar-link {
  white-space: nowrap;
  padding: 0 14px !important;
  height: 48px !important;
  border-radius: 0 !important;
}
body.nav-top .main-content {
  margin-left: 0 !important;
  padding-top: 48px !important;
}
body.nav-hidden .sidebar { display: none !important; }
body.nav-hidden .main-content { margin-left: 0 !important; }

/* WHY the group toggle/submenu need their own nav-top overrides
   (2026-09-06): nav-top's horizontal bar has no room for a dropdown, so
   the "Reports" parent button is hidden and its children render as flat
   inline pills instead - same pattern already used above for
   .sidebar-section, just extended to the nested group wrapper. */
body.nav-top .sidebar-group-toggle { display: none !important; }
body.nav-top .sidebar-submenu {
  display: contents !important; max-height: none !important;
}
body.nav-top .sidebar-submenu .sidebar-link { margin-left: 0 !important; }

/* ── Tab redesign — pill style ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: none !important;
  margin-bottom: 20px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 10px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  opacity: 1 !important;
  border: none !important;
  border-bottom: none !important;
  border-radius: 7px !important;
  background: transparent !important;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text) !important;
  background: var(--bg3) !important;
  opacity: 1 !important;
}
.tab.active {
  color: #fff !important;
  background: var(--accent) !important;
  font-weight: 700 !important;
  border-bottom: none !important;
}

/* Belt filter cards (Ranks, Stripes pages) - highlight uses school's primary color */
.belt-card {
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  user-select: none;
}
.belt-card:hover { transform: translateY(-2px); }
.belt-card.selected { border-color: var(--accent) !important; }

/* Tablet/phone menu as a slide-over drawer (2026-10-01, "some windows are
   overlapping"): below 1024px the open sidebar used to sit inside the page
   flow, so page pieces (avatars, search dropdowns) painted on top of it.
   It now floats above everything with a dimmed backdrop; tapping the
   backdrop closes it (nav.js). */
@media (max-width: 1024px) {
  body:not(.nav-hidden):not(.nav-top) .sidebar {
    position: fixed !important; top: var(--topbar-h); left: 0; bottom: 0;
    width: min(300px, 85vw); height: auto; z-index: 1500;
    box-shadow: 8px 0 30px rgba(0,0,0,.5);
  }
  body:not(.nav-hidden):not(.nav-top) #nav-drawer-backdrop { display: block; }
}
#nav-drawer-backdrop { display: none; position: fixed; left: 0; right: 0; bottom: 0; top: var(--topbar-h); background: rgba(0,0,0,.55); z-index: 1400; }


/* 2026-10-28 phone width (store app): '.app-layout' used a 1fr column, which can never get narrower than the top
   bar's natural width (~566px), so on phones every page scrolled sideways. minmax(0,1fr) lets it fit the screen;
   the logo block shrinks first, and below 600px the credits pill hides (still on the Credits page) and
   '+ Add Student' shortens to '+ Student'. */
@media (max-width: 1024px) {
  .app-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .topbar { min-width: 0; }
  .topbar-left { flex: 1 1 auto; min-width: 0; overflow: hidden; }
  .main-content { min-width: 0; }
}
@media (max-width: 600px) {
  .topbar-usage { display: none !important; }
  .topbar-right { gap: 8px; padding-right: 10px; }
  .topbar-add-student-btn { font-size: 0; padding: 8px 12px; }
  .topbar-add-student-btn::before { content: '+ Student'; font-size: 12px; }
  .topbar-logo img { height: 40px !important; max-width: 48px !important; margin-right: 6px !important; }
}
