/* ============================================================
   CalCounter — identidade Treinando com Biba & Rapha
   (preto + dourado, grunge/academia — ver ../assets/site.css)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..600;1,9..144,400..500&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --bg: #121719;
  --surface: #1b2327;
  --surface-2: #161d20;
  --border: #2a3439;
  --ink: #eef2f1;
  --ink-2: #9fb0ad;
  --ink-3: #6c7a77;
  --gold: #7fd9c4;
  --gold-2: #a8e9d9;
  --gold-deep: #4fae99;
  --green: #4ade80;
  --red: #e06a55;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Poppins', system-ui, sans-serif;
  --font-logo: 'Fraunces', Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* o atributo hidden SEMPRE esconde — mesmo quando a classe define display próprio
   (sem isso, .login-overlay { display:flex } vencia o hidden e o popup não saía) */
[hidden] { display: none !important; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(127,217,196,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(127,217,196,.06), transparent 60%),
    #101517;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  min-height: 100vh;
}

/* ---------- topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(14,18,20,.92);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand-side { display: flex; align-items: center; gap: 14px; }
.back { display: block; line-height: 0; transition: .15s; }
.back .emblem {
  height: 42px; width: auto; display: block;
}
.back:hover { transform: scale(1.06); }
.logo {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.25rem; letter-spacing: 3px; text-transform: uppercase;
  color: var(--ink);
}
.logo span { color: var(--gold); }

.tabs { display: flex; gap: 8px; }
.tab {
  background: #151515; color: var(--ink-2);
  border: 1.5px solid var(--border); border-radius: 6px;
  padding: 9px 20px; cursor: pointer; transition: .15s;
  font-family: var(--font-display); font-size: .85rem;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.tab:hover { color: var(--ink); border-color: var(--gold); }
.tab.active {
  background: linear-gradient(180deg, var(--gold-2), var(--gold-deep));
  color: #0d1416; border-color: transparent;
  box-shadow: 0 6px 18px rgba(127,217,196,.25);
}

/* menu p/ os outros apps do Eu Melhor */
.apps-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.apps-nav a {
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .78rem;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 8px 12px; border: 1.5px solid transparent; border-radius: 999px; transition: .15s;
}
.apps-nav a:hover { color: var(--ink); border-color: var(--gold); }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.date-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px; color: var(--ink-2);
}

/* minmax(0,1fr): sem isso o conteúdo (ex.: canvas largo) trava a largura mínima do card */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card.wide { grid-column: 1 / -1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.card h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: .95rem; text-transform: uppercase; letter-spacing: 2px;
  color: var(--gold); margin-bottom: 16px;
}

/* ---------- medidor ---------- */
.gauge-card { text-align: center; }
.gauge-wrap { position: relative; width: 260px; margin: 0 auto; }
.gauge-wrap canvas { display: block; }
.gauge-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.gauge-value {
  font-family: var(--font-display); font-weight: 600;
  font-size: 2.7rem; color: var(--ink);
  text-shadow: 0 4px 18px rgba(127,217,196,.25);
}
.gauge-label { color: var(--ink-3); font-size: .8rem; letter-spacing: 1px; font-weight: 600; }
.gauge-status {
  margin-top: 6px; font-size: .95rem; font-weight: 700; letter-spacing: .5px; min-height: 1.4em;
}
.gauge-status.ok   { color: var(--green); }
.gauge-status.warn { color: var(--gold); }
.gauge-status.over { color: var(--red); }

.stats { display: flex; justify-content: center; gap: 40px; margin-top: 14px; }
.stat { display: flex; flex-direction: column; }
.stat-label { color: var(--ink-3); font-size: .72rem; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.stat-value { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; }

/* ---------- formulários ---------- */
.add-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.add-form select, .add-form input, .date-row input {
  background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: .95rem; font-family: var(--font-body); font-weight: 500;
  color-scheme: dark;
}
.add-form select { flex: 1; min-width: 160px; }
.add-form input[type="number"] { width: 90px; }
.add-form input[type="text"] { flex: 1; min-width: 160px; }
.add-form select:focus, .add-form input:focus, .date-row input:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(127,217,196,.15);
}
.unit { color: var(--ink-3); font-size: .85rem; font-weight: 600; }

.qty-box { display: inline-flex; align-items: center; gap: 6px; }
.qty-box .unit { min-width: 20px; }
#foodUnit { flex: 0 1 auto; min-width: 0; }

.hint { color: var(--ink-3); font-size: .8rem; margin: -4px 0 12px; min-height: 1.2em; }

.or-divider {
  color: var(--ink-3); font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px;
  font-family: var(--font-display);
  margin: 2px 0 10px; display: flex; align-items: center; gap: 10px;
}
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 1px dashed #ffffff1a; }

.btn {
  border: none; border-radius: 8px; padding: 10px 20px;
  font-family: var(--font-display); font-weight: 600; font-size: .9rem;
  letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: .15s;
}
.btn-primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold-deep));
  color: #0d1416;
  box-shadow: 0 6px 18px rgba(127,217,196,.25);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-del, .btn-edit, .btn-ok {
  background: transparent; color: var(--ink-3); border: 1px solid transparent;
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 1rem;
}
.btn-del:hover  { color: var(--red);   border-color: var(--red); }
.btn-edit:hover { color: var(--gold);  border-color: var(--gold); }
.btn-ok:hover   { color: var(--green); border-color: var(--green); }

/* ---------- lista do dia ---------- */
.entry-list { list-style: none; max-height: 300px; overflow-y: auto; }
.entry-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px dashed #ffffff14;
}
.entry-time { color: var(--ink-3); font-size: .8rem; width: 42px; }
.entry-name { flex: 1; }
.entry-qty  { color: var(--ink-2); font-size: .85rem; }
.entry-kcal {
  color: var(--gold); font-weight: 800; min-width: 76px; text-align: right;
}
.empty-msg { color: var(--ink-3); font-style: italic; padding: 8px 2px; }

/* ---------- gráfico semanal ---------- */
.chart-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(127,217,196,.3) transparent;
}
.chart-wrap canvas { display: block; cursor: grab; }
.chart-wrap canvas:active { cursor: grabbing; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #121212f2; border: 1px solid var(--gold);
  border-radius: 8px; padding: 8px 12px; font-size: .85rem;
  box-shadow: 0 10px 26px rgba(0,0,0,.55); white-space: nowrap;
  transform: translate(-50%, -110%);
}
.tooltip .t-date { color: var(--ink-2); font-size: .75rem; }
.tooltip .t-val  { color: var(--gold); font-weight: 800; }
.tooltip .t-prot { color: var(--green); font-weight: 700; font-size: .82rem; }

.chart-legend { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none;
}
.chart-legend .dot-kcal { background: #2f9e8a; }
.chart-legend .dot-prot { background: #16a34a; margin-left: 10px; }

.table-view { margin-top: 12px; color: var(--ink-2); }
.table-view summary { cursor: pointer; font-size: .85rem; }
.table-view table, .food-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table-view th, .table-view td, .food-table th, .food-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid #ffffff14; font-size: .92rem;
}
.table-view th, .food-table th {
  font-family: var(--font-display); font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; font-size: .72rem; letter-spacing: 1.5px;
}
.food-table td:nth-child(2) { color: var(--gold); font-weight: 700; }
.food-table td:last-child { text-align: right; }
.food-table .row-actions { white-space: nowrap; }

/* tabela maior que a tela (ex.: linha em edição no celular) rola na horizontal */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(127,217,196,.3) transparent;
}

/* linha em modo de edição */
.food-table tr.editing input, .food-table tr.editing select {
  background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--gold); border-radius: 6px;
  padding: 5px 8px; font-size: .9rem; font-family: var(--font-body); color-scheme: dark;
}
.food-table tr.editing input[type="text"] { width: 100%; min-width: 110px; }
.food-table tr.editing input[type="number"] { width: 72px; }
.food-table tr.editing input:focus, .food-table tr.editing select:focus { outline: none; }

/* ---------- login por e-mail ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,8,8,.94); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 36px 32px; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 0 40px rgba(127,217,196,.10);
}
.login-box img { margin-bottom: 14px; }
.login-box h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 1.4rem;
  letter-spacing: 3px; margin-bottom: 8px;
}
.login-box h2 span { color: var(--gold); }
.login-box p { color: var(--ink-2); font-size: .9rem; margin-bottom: 18px; line-height: 1.45; }
.login-box input {
  width: 100%; background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 8px; padding: 12px 14px;
  font-family: var(--font-body); font-weight: 600; font-size: 1rem; text-align: center;
  margin-bottom: 12px; color-scheme: dark;
}
.login-box input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(127,217,196,.15); }
.login-box .btn { width: 100%; padding: 13px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: .82rem; font-weight: 600;
  background: #151515; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 6px 6px 14px; max-width: 260px;
}
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip button {
  border: none; background: transparent; color: var(--gold); cursor: pointer;
  font-family: var(--font-display); font-size: .72rem; letter-spacing: 1px;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
}
.user-chip button:hover { background: rgba(127,217,196,.12); }

/* ---------- perfil ---------- */
.profile-line { font-size: 1rem; color: var(--ink-2); margin-bottom: 8px; }
.profile-line b { font-family: var(--font-display); font-weight: 600; color: var(--gold); font-size: 1.25rem; }
.goldlink { color: var(--gold); font-weight: 700; text-decoration: none; }
.goldlink:hover { text-decoration: underline; }

/* ---------- macros ---------- */
.macro-line {
  margin-top: 12px; color: var(--ink-2); font-size: .9rem; font-weight: 600; text-align: center;
}
.macro-line b { color: var(--gold); font-weight: 700; }
.macro-line b.hit { color: var(--green); }   /* meta de proteína batida */
.macro-in { width: 84px; }
.macro-td { color: var(--ink-2); }
.macro-edit {
  width: 64px; background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--gold); border-radius: 6px; padding: 5px 6px;
  font-size: .88rem; font-family: var(--font-body); color-scheme: dark;
}
.macro-edit:focus { outline: none; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--gold); }
th.sortable.sorted-desc::after { content: ' ▼'; color: var(--gold); font-size: .7em; }
th.sortable.sorted-asc::after  { content: ' ▲'; color: var(--gold); font-size: .7em; }

/* ---------- busca TACO ---------- */
.taco-search { position: relative; margin-bottom: 14px; }
.taco-search input {
  width: 100%; background: var(--surface-2); color: var(--ink);
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 10px 12px;
  font-family: var(--font-body); font-weight: 500; font-size: .95rem; color-scheme: dark;
}
.taco-search input:focus { outline: none; border-color: var(--gold); border-style: solid; }
.taco-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  list-style: none; max-height: 300px; overflow-y: auto;
  background: #141312; border: 1px solid var(--gold-deep); border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0,0,0,.6);
}
.taco-results li {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px dashed #ffffff12;
  display: flex; align-items: baseline; gap: 10px;
}
.taco-results li:last-child { border-bottom: none; }
.taco-results li:hover { background: rgba(127,217,196,.10); }
.taco-results .t-name { flex: 1; font-size: .92rem; }
.taco-results .t-cat { color: var(--ink-3); font-size: .72rem; }
.taco-results .t-kcal { color: var(--gold); font-weight: 700; font-size: .88rem; white-space: nowrap; }

/* ---------- mobile (por último para vencer as regras base) ---------- */
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .card.wide { grid-column: auto; }

  .topbar { padding: 12px 16px; }
  .brand-side { width: 100%; justify-content: space-between; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 0; text-align: center; }
  .apps-nav { width: 100%; justify-content: center; }

  main { padding: 16px 12px 40px; }
  .card { padding: 16px 14px; }

  /* seletor de alimento ocupa a linha toda; qtd + botão dividem a de baixo */
  .add-form select { flex: 1 1 100%; min-width: 0; }
  .add-form input[type="number"] { flex: 1; width: auto; min-width: 0; }
  .add-form .qty-box { flex: 1; }
  .add-form .btn-primary { flex: 2; }

  .stats { gap: 24px; }
  .entry-list { max-height: none; overflow-y: visible; }
}
