/* ══════════════════════════════════════════════════════════
   Atlas Coach — Design System v2.0 (dark, alinhado ao Atlas)
   ══════════════════════════════════════════════════════════ */
:root {
  --bg:      #0f1117;
  --bg2:     #1a1d2e;
  --bg3:     #252840;
  --bg4:     #2d3148;
  --accent:  #7c3aed;
  --accent2: #a855f7;
  --accent3: #06b6d4;
  --green:   #10b981;
  --orange:  #f59e0b;
  --red:     #ef4444;
  --blue:    #3b82f6;
  --text:    #e2e8f0;
  --text2:   #94a3b8;
  --border:  #2d3148;
  --brand:   #7c3aed;
  --brand-2: #a855f7;
  /* legacy aliases so app.js tokens still work */
  --card:    var(--bg2);
  --ink:     var(--text);
  --muted:   var(--text2);
  --ok:      var(--green);
  --warn:    var(--orange);
  --danger:  var(--red);
  --surface2: var(--bg3);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Micro-transitions ── */
button, input, select, textarea, .tab, .mobile-nav button { transition: all .15s ease; }

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .9rem 1.2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-wrap { display: flex; align-items: center; gap: .75rem; }

.brand-logo {
  width: 40px; height: 40px;
  object-fit: contain;
  padding: 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  opacity: .9;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.subtitle { font-size: .78rem; color: var(--text2); margin: 0; }

.header-tools {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.session-area { font-size: .82rem; color: var(--text2); }

/* ── LAYOUT ── */
.container {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: .75rem .75rem 5.5rem;
  display: grid;
  gap: .7rem;
}

/* ── CARDS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

/* ── HERO ── */
.hero {
  display: grid;
  gap: .8rem;
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  overflow: hidden;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(124,58,237,.2), transparent 70%);
  pointer-events: none;
}

.hero img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  opacity: .85;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
  color: var(--accent2);
  font-weight: 700;
}

/* ── FORMS ── */
.grid { display: grid; gap: .65rem; margin-top: .7rem; }
.two-col, .three-col { grid-template-columns: 1fr; }
.full { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  font-size: .88rem;
  color: var(--text2);
}

input, select, textarea {
  font: inherit;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .62rem .72rem;
  color: var(--text);
  min-height: 42px;
}

input::placeholder, textarea::placeholder { color: #4a5568; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(168,85,247,.12);
}

/* ── BUTTONS ── */
button { font: inherit; border: none; border-radius: 8px; padding: .68rem 1rem; min-height: 42px; cursor: pointer; }

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
}
.primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124,58,237,.4); }

.secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.secondary:hover { background: var(--bg4); border-color: var(--accent2); }

/* ── TAB ROW (coach desktop) ── */
.tab-row {
  display: none; /* shown via desktop-mode */
}

/* ── COACH GROUPED TABS ── */
.coach-tabs-bar {
  display: none;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  overflow-x: auto;
  gap: 0;
}

.coach-tabs-group {
  display: flex;
  align-items: center;
  gap: 0;
}

.coach-tabs-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #3d4466;
  padding: 0 8px;
  white-space: nowrap;
}

.coach-tabs-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* individual tab button */
.tab {
  background: transparent;
  color: var(--text2);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: .7rem .9rem;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
  display: flex; align-items: center; gap: .35rem;
}

.tab:hover { color: var(--text); background: rgba(255,255,255,.03); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent2); font-weight: 600; }

.tab.extra { opacity: .65; }
.tab.extra:hover { opacity: 1; }

/* ── ROLE STRIP ── */
.role-strip {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}

.role-welcome { font-weight: 600; font-size: .9rem; }

/* ── TAB CONTENTS ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── COACH NOTE ── */
.coach-note {
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  border-radius: 8px;
  padding: .6rem .75rem;
  font-size: .85rem;
  margin: .5rem 0;
}

/* ── KPI GRID ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .55rem;
  margin-top: .75rem;
}

.kpi {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem;
}

.kpi strong { display: block; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.kpi small { font-size: .75rem; color: var(--text2); }

/* ── STACK / ITEM ── */
.stack {
  display: grid;
  gap: .55rem;
  margin-top: .72rem;
}

.item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem;
  font-size: .88rem;
}

.item strong { color: var(--text); }

/* ── ALERTS ── */
.alerts { margin-top: .72rem; display: grid; gap: .45rem; }

.badge {
  width: fit-content;
  border-radius: 999px;
  padding: .22rem .6rem;
  font-size: .82rem;
  font-weight: 600;
}
.ok    { background: rgba(16,185,129,.15); color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.warn  { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.danger { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ── QUICK ACTIONS (buttons row) ── */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: .65rem 0;
}

/* ── CHAT BUBBLES ── */
.chat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem;
  min-height: 120px;
  max-height: 280px;
  overflow-y: auto;
  display: grid;
  gap: .5rem;
}

.bubble {
  max-width: 88%;
  padding: .52rem .7rem;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.4;
}
.bubble.user      { justify-self: end; background: rgba(124,58,237,.25); border: 1px solid rgba(168,85,247,.3); }
.bubble.assistant { justify-self: start; background: var(--bg4); border: 1px solid var(--border); }

/* ── MOBILE BOTTOM NAV ── */
.mobile-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: .35rem .35rem calc(.35rem + env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
}

.mobile-nav button {
  min-height: 50px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  background: transparent;
  color: var(--text2);
  padding: .3rem .2rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none;
}
.mobile-nav button .nav-icon { font-size: 1.2rem; }
.mobile-nav button.active { color: var(--accent2); background: rgba(168,85,247,.1); }
.mobile-nav button.active .nav-icon { filter: drop-shadow(0 0 6px var(--accent2)); }

/* ── BACKDROP + SHEETS ── */
.mobile-backdrop {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
}

.mobile-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0; z-index: 46;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  padding: .75rem;
  max-height: min(72vh, 560px);
  overflow-y: auto;
  display: grid;
  gap: .4rem;
}

.sheet-inner {
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* student-more sheet override */
#studentMoreSheet {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 900;
  display: flex; align-items: flex-end;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 82px; z-index: 60;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: .55rem .9rem;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  font-size: .85rem;
  white-space: nowrap;
}

/* ── QUICK ACTION BAR ── */
.quick-action-bar {
  position: fixed; right: 14px; bottom: 90px; z-index: 45;
  display: grid; gap: .4rem;
}
.quick-action-bar button {
  border-radius: 999px;
  padding: .42rem .8rem;
  font-size: .78rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  min-height: 38px;
}

/* ── TRAINING MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px 20px 16px 16px;
  padding: 1.5rem;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 -4px 40px rgba(0,0,0,.6);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}

/* ── PROGRESS STREAK ── */
.streak-week {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
.streak-week.hit  { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.streak-week.miss { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

/* ── MISC ELEMENTS ── */
.exercise-line {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .45rem;
  border-bottom: 1px solid var(--border); padding: .5rem 0;
}
.exercise-line:last-child { border-bottom: 0; }

.yt-link {
  text-decoration: none; color: #fff;
  background: #dc2626;
  border-radius: 999px; padding: .24rem .6rem;
  font-size: .78rem; white-space: nowrap;
}

.plan-title { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.day-block {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem; margin-top: .45rem;
}

/* ── STUDENT WORKOUT INIT BUTTON ── */
#startTrainingBtn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700;
  font-size: 1.1rem;
  padding: 1.1rem 2rem;
  border-radius: 14px;
  width: 100%; max-width: 360px;
  box-shadow: 0 6px 20px rgba(124,58,237,.4);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
#startTrainingBtn:hover { opacity: .9; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,.5); }

/* ── TAGS ── */
.tag {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .18rem .5rem;
  font-size: .78rem;
  color: var(--text2);
}
.tag.blue  { background: rgba(59,130,246,.12); color: #60a5fa; border-color: rgba(59,130,246,.25); }
.tag.green { background: rgba(16,185,129,.12); color: #34d399; border-color: rgba(16,185,129,.25); }

/* ══════════════════════════════════════
   DESKTOP MODE
   ══════════════════════════════════════ */
body.desktop-mode .container {
  width: min(100%, 1140px);
  padding-bottom: 2rem;
}
body.desktop-mode .hero { grid-template-columns: 1.2fr 1fr; align-items: center; }
body.desktop-mode .hero img { height: 220px; }

body.desktop-mode .coach-tabs-bar {
  display: flex;
}

body.desktop-mode .tab-row { display: flex; flex-wrap: wrap; gap: 0; }

body.desktop-mode .mobile-nav     { display: none !important; }
body.desktop-mode .quick-action-bar { display: none !important; }
body.desktop-mode .mobile-backdrop { display: none !important; }

body.desktop-mode .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
body.desktop-mode .two-col   { grid-template-columns: repeat(2, 1fr); }
body.desktop-mode .three-col { grid-template-columns: repeat(3, 1fr); }

/* ══════════════════════════════════════
   MOBILE / APP SHELL
   ══════════════════════════════════════ */
body.app-shell-mobile {
  background: var(--bg);
}

body.app-shell-mobile .topbar { border-radius: 0 0 16px 16px; padding: .7rem 1rem; }
body.app-shell-mobile .brand-logo { width: 32px; height: 32px; padding: 4px; }
body.app-shell-mobile h1 { font-size: .95rem; }
body.app-shell-mobile .subtitle { display: none; }
body.app-shell-mobile .session-area { font-size: .75rem; }

body.app-shell-mobile .container {
  width: 100%; margin: 0;
  padding: .6rem .6rem calc(5.8rem + env(safe-area-inset-bottom));
  gap: .55rem;
}

body.app-shell-mobile .card { border-radius: 14px; padding: .8rem; }
body.app-shell-mobile .role-strip { padding: .6rem .75rem; }
body.app-shell-mobile .role-welcome { font-size: .85rem; }
body.app-shell-mobile .tab-content h2 { font-size: 1rem; }
body.app-shell-mobile label { font-size: .82rem; }
body.app-shell-mobile input,
body.app-shell-mobile select,
body.app-shell-mobile textarea { min-height: 46px; font-size: .95rem; }
body.app-shell-mobile .kpi-grid { grid-template-columns: repeat(2, 1fr); }

/* student greeting hero */
#studentHomeGreeting {
  font-size: 1.3rem; font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent3));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── FOOTER ── */
.footer {
  text-align: center;
  color: var(--text2);
  padding: .5rem .8rem 1rem;
  font-size: .78rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 979px) {
  .container { padding-bottom: calc(5.8rem + env(safe-area-inset-bottom)); }
  .header-tools > button { display: none; }
  .hero img { height: 130px; }
  .quick-action-bar { display: none !important; }
}

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