/* ============================================================
   Academia App Aquiles - Design System
   ============================================================ */
:root {
  --azul: #2563eb;
  --azul-d: #1d4ed8;
  --verde: #16a34a;
  --verde-l: #22c55e;
  --laranja: #f97316;
  --vermelho: #dc2626;
  --amarelo: #eab308;
  --roxo: #7c3aed;
  --zap: #25d366;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --txt: #0f172a;
  --txt-2: #475569;
  --txt-3: #94a3b8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --header-h: 60px;
  --nav-h: 64px;
  --max: 720px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--azul); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.app { max-width: var(--max); margin: 0 auto; min-height: 100%; position: relative; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.page { padding: 16px; }
.page.with-header { padding-top: calc(var(--header-h) + 12px); }

/* ---------- Header ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  max-width: var(--max); margin: 0 auto;
}
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.topbar .icon-btn { background: none; border: none; padding: 8px; border-radius: 50%; cursor: pointer; color: var(--txt-2); position: relative; }
.topbar .icon-btn:active { background: var(--surface-2); }

.badge-dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; background: var(--vermelho); border-radius: 50%; border: 2px solid var(--surface); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; max-width: var(--max); margin: 0 auto;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--txt-3); font-size: 11px; font-weight: 600;
}
.bottom-nav a.active { color: var(--azul); }
.bottom-nav a svg { width: 24px; height: 24px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-flush { padding: 0; overflow: hidden; }
.card h2, .card h3 { font-size: 15px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--txt-3); margin: 4px 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-weight: 700; font-size: 15px; background: var(--azul); color: #fff;
  transition: transform .05s, filter .15s; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; }
.btn-green { background: var(--verde); }
.btn-zap { background: var(--zap); }
.btn-orange { background: var(--laranja); }
.btn-red { background: var(--vermelho); }
.btn-ghost { background: var(--surface-2); color: var(--txt); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--txt); }
.btn svg { width: 18px; height: 18px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--txt-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 15px; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--azul); }
.textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--txt-2); }
.chip-azul { background: #dbeafe; color: var(--azul-d); }
.chip-verde { background: #dcfce7; color: #15803d; }
.chip-laranja { background: #ffedd5; color: #c2410c; }
.chip-vermelho { background: #fee2e2; color: #b91c1c; }
.chip-roxo { background: #ede9fe; color: #6d28d9; }

/* ---------- Lists ---------- */
.list { list-style: none; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.list-item:last-child { border-bottom: none; }
.list-item .ava { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--txt-2); }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta .s { font-size: 13px; color: var(--txt-3); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 26px; font-weight: 800; line-height: 1; }
.stat .l { font-size: 12px; color: var(--txt-3); margin-top: 6px; font-weight: 600; }
.stat .ico { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }

/* ---------- Exercicio card ---------- */
.ex-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.ex-thumb { position: relative; aspect-ratio: 16/9; background: #0f172a; }
.ex-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ex-thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ex-thumb .play span { width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.ex-body { padding: 14px 16px; }
.ex-body .nome { font-size: 16px; font-weight: 800; }
.ex-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

/* ---------- Progress bar ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--verde); border-radius: 999px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: calc(var(--nav-h) + 16px); left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .2s ease; max-width: 90%; }
.toast.ok { background: var(--verde); }
.toast.err { background: var(--vermelho); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Modal / sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 80; display: none; align-items: flex-end; }
.sheet-backdrop.open { display: flex; }
.sheet { background: var(--surface); width: 100%; max-width: var(--max); margin: 0 auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; animation: sheetUp .25s ease; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .grab { width: 40px; height: 4px; background: var(--border); border-radius: 999px; margin: -6px auto 14px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 80px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; position: relative; word-wrap: break-word; }
.msg .time { font-size: 10px; opacity: .6; margin-top: 4px; display: block; }
.msg.recebida { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.enviada { background: var(--azul); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-bar { position: fixed; bottom: 0; left: 0; right: 0; max-width: var(--max); margin: 0 auto; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; z-index: 30; }
.chat-bar .input { flex: 1; border-radius: 999px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--txt-3); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 14px; opacity: .4; }
.empty p { font-size: 14px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 440px; margin: 0 auto; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .mark { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(135deg, var(--azul), var(--roxo)); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; box-shadow: var(--shadow-lg); }
.auth-logo h1 { font-size: 22px; font-weight: 800; }
.auth-logo p { color: var(--txt-3); font-size: 14px; margin-top: 4px; }
.tabs { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; padding: 10px; border: none; background: none; border-radius: 8px; font-weight: 700; color: var(--txt-3); cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--surface); color: var(--txt); box-shadow: var(--shadow); }

/* ---------- Util ---------- */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.text-c { text-align: center; }
.muted { color: var(--txt-3); }
.small { font-size: 13px; }
.bold { font-weight: 700; }
.hidden { display: none !important; }
.fab { position: fixed; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); right: 16px; width: 56px; height: 56px; border-radius: 50%; background: var(--azul); color: #fff; border: none; box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; z-index: 35; cursor: pointer; }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 760px) { .fab { right: calc(50% - var(--max)/2 + 16px); } }

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --surface: #1e293b; --surface-2: #334155;
    --border: #334155; --txt: #f1f5f9; --txt-2: #cbd5e1; --txt-3: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
  }
  .chip-azul { background: #1e3a8a; color: #bfdbfe; }
  .chip-verde { background: #14532d; color: #bbf7d0; }
  .chip-laranja { background: #7c2d12; color: #fed7aa; }
}
