/* ═══════════════════════════════════════════════════════════
   EVN — Calculadora de Déficit Calórico
   style.css
   ═══════════════════════════════════════════════════════════ */

:root {
  --green-deep:   #0f2b21;
  --green-dark:   #1a3c2f;
  --green-mid:    #2d6a4f;
  --green-accent: #4ecfb5;
  --green-light:  #a8e6d3;
  --green-pale:   #e8f7f2;
  --beige:        #f5f0e8;
  --beige-dark:   #ece4d4;
  --text-dark:    #1a1a1a;
  --text-mid:     #3d4d45;
  --text-muted:   #6b7c74;
  --gold:         #c9a84c;
  --warn-bg:      #fff8ec;
  --warn-fg:      #7a4f00;
  --warn-border:  #f0c96a;
  --danger-bg:    #fff0f0;
  --danger-fg:    #8b1a1a;
  --danger-border:#f5b0b0;
  --white:        #ffffff;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(15,43,33,0.10);
  --shadow-lg:    0 12px 48px rgba(15,43,33,0.18);
  --transition:   .2s ease;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--beige);
  color: var(--text-dark);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(78,207,181,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 90% 100%, rgba(45,106,79,0.09) 0%, transparent 60%);
  pointer-events: none;
}

/* ── LAYOUT ── */
.page-wrap {
  position: relative; z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ── HEADER ── */
header {
  padding: 44px 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.back-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.03em;
  align-self: flex-start;
  transition: color var(--transition);
}
.back-link:hover { color: var(--green-mid); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--green-deep);
  color: var(--green-accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 100px;
}
.badge svg { width: 12px; height: 12px; fill: var(--green-accent); flex-shrink: 0; }

h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--green-deep);
  line-height: 1.15;
  max-width: 580px;
}
h1 em { font-style: italic; color: var(--green-mid); }

.sub {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 300;
  max-width: 460px;
  line-height: 1.65;
}

.ref-tag {
  display: inline-block;
  background: var(--green-pale);
  border: 1px solid var(--green-light);
  color: var(--green-mid);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px;
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  background: var(--green-deep);
  padding: 16px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  color: var(--white);
  font-weight: 400;
}
.card-header .icon {
  width: 28px; height: 28px;
  background: rgba(78,207,181,0.15);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.card-body { padding: 26px; }
.card-body.no-pad { padding: 0; }

/* ── FORM ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-grid .full-col { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.unit-tag {
  font-size: 10px;
  background: var(--green-pale);
  color: var(--green-mid);
  padding: 1px 6px;
  border-radius: 100px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

input[type=number],
select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--beige-dark);
  border-radius: var(--radius-sm);
  background: var(--beige);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dark);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input[type=number]:focus,
select:focus {
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px rgba(78,207,181,0.18);
  background: var(--white);
}
input[type=number]::-webkit-inner-spin-button { opacity: 0.4; }

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232d6a4f' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

/* ── SEGMENTED CONTROL ── */
.seg-ctrl {
  display: flex;
  border: 1.5px solid var(--beige-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--beige);
}
.seg-ctrl button {
  flex: 1;
  padding: 11px 8px;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.seg-ctrl button:first-child { border-right: 1.5px solid var(--beige-dark); }
.seg-ctrl button.active {
  background: var(--green-deep);
  color: var(--green-accent);
}
.seg-ctrl button:focus-visible {
  outline: 2px solid var(--green-accent);
  outline-offset: -2px;
}

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: var(--beige-dark);
  margin: 22px 0;
}

.section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--beige-dark);
}

/* ── INPUT ERROR ── */
.input-error {
  font-size: 13px;
  color: var(--danger-fg);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 4px;
  display: none;
}
.input-error.visible { display: block; }

/* ── CALCULATE BUTTON ── */
.btn-calc {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--green-mid) 0%, var(--green-deep) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(45,106,79,0.28);
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-calc:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(45,106,79,0.38); }
.btn-calc:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(45,106,79,0.28); }
.btn-calc:focus-visible { outline: 2px solid var(--green-accent); outline-offset: 3px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  display: none;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.btn-calc.loading .spinner { display: block; }
.btn-calc.loading .btn-text { display: none; }
.btn-calc.loading { cursor: wait; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESULTS PANEL ── */
#results-panel {
  display: none;
}
#results-panel.visible {
  display: block;
  animation: fadeUp .4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── ALERT ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  line-height: 1.6;
}
.alert.ok     { background: var(--green-pale); color: var(--green-mid); border: 1px solid var(--green-light); }
.alert.warn   { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); }
.alert.danger { background: var(--danger-bg); color: var(--danger-fg); border: 1px solid var(--danger-border); }
.alert-icon   { font-size: 17px; flex-shrink: 0; margin-top: 1px; }

/* ── RESULTS TILES ── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.result-tile {
  background: var(--beige);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  border: 1.5px solid var(--beige-dark);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.result-tile.highlight {
  background: var(--green-deep);
  border-color: var(--green-mid);
}

.tile-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.result-tile.highlight .tile-label { color: var(--green-light); }

.tile-value {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--green-deep);
}
.result-tile.highlight .tile-value { color: var(--green-accent); }

.tile-unit {
  font-size: 11px;
  color: var(--text-muted);
}
.result-tile.highlight .tile-unit { color: rgba(168,230,211,0.75); }

.tile-tip {
  font-size: 10.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}
.result-tile.highlight .tile-tip { color: rgba(168,230,211,0.55); }

/* ── CHART ── */
.chart-title {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  color: var(--green-deep);
  margin-bottom: 3px;
}
.chart-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.chart-wrap {
  background: var(--beige);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--beige-dark);
  padding: 16px 8px 8px;
  overflow: hidden;
}
#weightChart {
  width: 100%;
  height: 260px;
  display: block;
}

/* ── TABLE ── */
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--green-deep);
  color: var(--green-accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px 14px;
  text-align: center;
  white-space: nowrap;
}
thead th:first-child { border-radius: 0; }

tbody tr:nth-child(even) td { background: var(--beige); }
tbody tr:nth-child(odd) td  { background: var(--white); }

tbody td {
  padding: 10px 14px;
  text-align: center;
  color: var(--text-dark);
  border-bottom: 1px solid var(--beige-dark);
  white-space: nowrap;
}
tbody tr.goal-row td {
  background: var(--green-pale) !important;
  font-weight: 600;
  color: var(--green-mid);
}
.loss-pos { color: var(--green-mid); font-weight: 500; }

/* ── SCIENCE BOX ── */
.science-box {
  background: var(--green-deep);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--white);
  margin-bottom: 20px;
}
.science-box h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--green-accent);
  margin-bottom: 14px;
}
.science-box p {
  font-size: 13.5px;
  line-height: 1.75;
  color: rgba(255,255,255,0.78);
  margin-bottom: 10px;
}
.science-box strong { color: var(--white); }

.eq-row {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 18px 0;
  padding: 18px;
  background: rgba(78,207,181,0.07);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--green-accent);
}
.eq {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--green-accent);
  line-height: 1.5;
}
.eq-comment { color: rgba(78,207,181,0.5); }
.eq-desc {
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 4px;
  font-family: 'DM Sans', sans-serif;
}
.science-note {
  font-size: 11.5px !important;
  color: rgba(255,255,255,0.4) !important;
  margin-top: 4px !important;
}

/* ── FOOTER ── */
footer {
  text-align: center;
  padding: 28px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.9;
}
.footer-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: var(--green-mid);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}
footer strong { color: var(--green-mid); }
footer em { font-style: italic; }
.footer-brand {
  color: var(--green-mid);
  font-weight: 600;
  margin-top: 8px;
}
.footer-legal {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  max-width: 420px;
  margin: 6px auto 0;
  line-height: 1.6;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .card-body { padding: 20px; }
  .science-box { padding: 22px 18px; }
  header { padding: 32px 0 28px; }
}
@media (max-width: 400px) {
  .results-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
}

/* ── FOCUS VISIBLE (acessibilidade) ── */
:focus-visible {
  outline: 2px solid var(--green-accent);
  outline-offset: 2px;
}

/* ── PRINT ── */
@media print {
  body::before { display: none; }
  .btn-calc, header .badge { display: none; }
  .card { box-shadow: none; border: 1px solid var(--beige-dark); }
  .science-box { background: var(--green-pale); color: var(--text-dark); }
  .science-box h3, .eq { color: var(--green-mid); }
}
