/* ==========================================================================
   m-app.css — Unified mobile + desktop shell for customer & public pages
   Aligned with: customer-shell-glass.css tokens, NexiBook palette, bottom-nav.
   Scope: customer + public pages only. Tenant/trainer untouched.

   Loading order: tokens.css → m-app.css → page-specific styles
   Wrap page body with: <body class="m-app" data-theme="dark">

   Breakpoints:
     mobile:  < 1024px → top-bar + bottom-nav
     desktop: ≥ 1024px → top-bar + side-nav (bottom-nav auto-hides)
   ========================================================================== */

/* ---------- Tokens (single source of truth) ---------- */
.m-app {
  /* Surfaces */
  --bg:           #050505;
  --bg-2:         #0a0a0b;
  --surface:      #0f0f10;
  --surface-2:    #17171a;
  --surface-3:    #1d1d21;
  --surface-hov:  #1a1a1c;
  --line:         rgba(255,255,255,0.08);
  --line-2:       rgba(255,255,255,0.04);
  --border-gold:  rgba(255,215,0,0.12);
  --border-gold-strong: rgba(255,215,0,0.30);

  /* Text */
  --ink:          #ffffff;
  --ink-2:        #c6c6cc;
  --ink-3:        #8e8e96;
  --ink-4:        #5c5c63;

  /* Accent (NexiBook gold) */
  --gold:         #FFD700;
  --gold-strong:  #E6C200;
  --gold-wash:    rgba(255,215,0,0.10);
  --gold-ring:    rgba(255,215,0,0.25);

  /* State */
  --ok:           #10B981;
  --warn:         #F59E0B;
  --danger:       #EF4444;
  --info:         #6366f1;

  /* Layout */
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --gap:          12px;
  --topbar-h:     56px;
  --bottomnav-h:  64px;
  --sidenav-w:    240px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);

  /* Type */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.m-app[data-theme="light"] {
  --bg: #f7f7f9; --bg-2: #ffffff; --surface: #ffffff;
  --surface-2: #f7f7f9; --surface-3: #eeeef2; --surface-hov: #efeff3;
  --line: #e6e7eb; --line-2: #f0f0f3;
  --ink: #0c0c0f; --ink-2: #3f3f46; --ink-3: #6b6b74; --ink-4: #9a9aa3;
  --gold: var(--nb-gold-light-legacy, #b88b00); --gold-strong: #9c7400;
}

/* ---------- Base reset (scoped) ---------- */
.m-app, .m-app *, .m-app *::before, .m-app *::after { box-sizing: border-box; }
.m-app {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background-image: radial-gradient(1000px 400px at 50% -10%, var(--gold-wash), transparent 60%);
  background-attachment: fixed;
}
.m-app a { color: var(--gold); text-decoration: none; }
.m-app button { font-family: var(--font); cursor: pointer; }
.m-app ::selection { background: var(--gold); color: #000; }

/* ---------- Top Bar (shared mobile + desktop) ---------- */
.m-topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 16px;
  padding-top: var(--safe-top);
  background: rgba(11,11,12,0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-gold-strong);
}
.m-topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-topbar__brand img { height: 28px; width: auto; }
.m-topbar__title { font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-topbar__spacer { flex: 1; }
.m-topbar__actions { display: flex; align-items: center; gap: 8px; }
.m-topbar__btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); transition: background .15s;
}
.m-topbar__btn:hover { background: var(--surface-hov); }

/* Lang switcher */
.m-langswitch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.m-langswitch button {
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  border: none; background: transparent; color: var(--ink-3);
  border-radius: 999px; transition: all .15s;
}
.m-langswitch button.active { background: var(--gold); color: #000; }
/* P12: 44x44 hit area without changing the 37x23 look (the neighbouring button owns the 2px gap) */
.m-langswitch button { position: relative; }
.m-langswitch button::before { content: ""; position: absolute; inset: -17px -1px -5px -8px; }
.m-langswitch button:last-child::before { inset: -17px -9px -5px -1px; }

/* ---------- Layout shell ---------- */
.m-shell { display: flex; flex-direction: column; min-height: 100vh; }
.m-main {
  flex: 1; padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 8px);
}

/* Desktop side-nav layout */
@media (min-width: 1024px) {
  .m-shell { flex-direction: row; }
  .m-shell > .m-topbar { display: none; }
  .m-main { margin-left: var(--sidenav-w); padding-bottom: 0; }
}

/* ---------- Side Nav (desktop ≥1024px) ---------- */
.m-sidenav {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidenav-w);
  z-index: 90;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  flex-direction: column;
  padding: 20px 12px;
}
@media (min-width: 1024px) { .m-sidenav { display: flex; } }
.m-sidenav__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 20px; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.m-sidenav__brand img { height: 32px; }
.m-sidenav__brand span { font-size: 16px; font-weight: 700; color: var(--gold); }
.m-sidenav__tabs { display: flex; flex-direction: column; gap: 2px; }
.m-sidenav__tab {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.m-sidenav__tab:hover { background: var(--surface); color: var(--ink); }
.m-sidenav__tab.is-active { background: var(--gold-wash); color: var(--gold); }
.m-sidenav__tab svg { width: 20px; height: 20px; flex-shrink: 0; }
.m-sidenav__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }

/* Hide the existing bottom-nav at desktop breakpoint (already done in partial, repeated for safety) */
@media (min-width: 1024px) { .m-app .bottom-nav { display: none !important; } }

/* When body itself has .m-app and a sibling .m-sidenav exists, push body content
   right by sidenav width on desktop. This works for the m-calendar layout
   (body = flex column, fixed full-screen) without restructuring the page. */
@media (min-width: 1024px) {
  body.m-app { padding-left: var(--sidenav-w); }
  body.m-app.mc-embed { padding-left: 0; } /* embed mode: no shell, no offset */
}

/* ---------- Cards / surfaces ---------- */
.m-card {
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color .15s, background .15s;
}
.m-card:hover { background: var(--surface-hov); }
.m-card--selected { border-color: var(--gold); background: var(--gold-wash); }

/* ---------- Buttons ---------- */
.m-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; line-height: 1;
  background: var(--surface); color: var(--ink);
  transition: all .15s;
}
.m-btn:hover { background: var(--surface-hov); }
.m-btn--primary { background: var(--gold); color: #000; }
.m-btn--primary:hover { background: var(--gold-strong); }
.m-btn--ghost { background: transparent; border-color: var(--line); }
.m-btn--danger { background: var(--danger); color: #fff; }
.m-btn--sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.m-btn--block { width: 100%; }

/* ---------- Badges / pills ---------- */
.m-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.2;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.m-badge--paid    { background: rgba(16,185,129,0.15); color: var(--ok); border-color: rgba(16,185,129,0.30); }
.m-badge--pending { background: rgba(245,158,11,0.15); color: var(--warn); border-color: rgba(245,158,11,0.30); }
.m-badge--gold    { background: var(--gold-wash); color: var(--gold); border-color: var(--border-gold-strong); }
.m-badge--danger  { background: rgba(239,68,68,0.15); color: var(--danger); border-color: rgba(239,68,68,0.30); }

/* ---------- Inputs ---------- */
.m-input, .m-select, .m-textarea {
  width: 100%; padding: 10px 12px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-family: var(--font); font-size: 14px;
}
.m-input::placeholder, .m-textarea::placeholder { color: var(--ink-4); }
.m-input:focus, .m-select:focus, .m-textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-ring); }

/* ---------- Container utilities ---------- */
.m-container { max-width: 100%; padding: 16px; }
@media (min-width: 1024px) {
  .m-container { max-width: 1200px; margin: 0 auto; padding: 24px 32px; }
}

/* ---------- Helpers ---------- */
.m-stack { display: flex; flex-direction: column; gap: var(--gap); }
.m-row   { display: flex; gap: var(--gap); align-items: center; }
.m-grow  { flex: 1; min-width: 0; }
.m-hide-mobile  { display: none; }
.m-hide-desktop { display: initial; }
@media (min-width: 1024px) {
  .m-hide-mobile  { display: initial; }
  .m-hide-desktop { display: none; }
}
