/* ============================================================
   TDEE Calculator — Nahnu Media v2.3.0
   Brand: #111 bg · #FF6A00 accent · white text · dark cards
   ============================================================ */

/* ---------- Reset & box model ---------- */
.tdee-wrap,
.tdee-wrap *,
.tdee-wrap *::before,
.tdee-wrap *::after {
  box-sizing: border-box;
}

/* ---------- CSS custom properties ---------- */
.tdee-wrap {
  --primary:        #FF6A00;
  --primary-dark:   #e05800;
  --primary-400:    #ff8533;
  --primary-light:  #ffa366;
  --surface:        #1a1a1a;
  --surface-2:      #222222;
  --surface-3:      #2a2a2a;
  --border:         #2e2e2e;
  --text:           #ffffff;
  --text-muted:     #8a8a8a;
  --text-secondary: #b0b0b0;
  --error:          #ff4d4d;
  --radius-card:    18px;
  --radius-input:   12px;
  --radius-pill:    999px;

  width: 100%;
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
}

/* ---------- Layout ---------- */
.tdee-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  min-width: 0;
}

@media (min-width: 900px) {
  .tdee-grid {
    grid-template-columns: 380px 1fr;
    gap: 20px;
  }
}

.tdee-grid > * { min-width: 0; width: 100%; }

/* ---------- Form card ---------- */
.tdee-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  min-width: 0;
}

.tdee-form { padding: 18px; }

/* "Units" section label */
.tdee-title {
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* ---------- Metric/Imperial tabs ---------- */
.tdee-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
  border: 1px solid var(--border);
  min-width: 0;
}

.tdee-tab {
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, transform 0.04s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tdee-tab:hover  { color: var(--text); }
.tdee-tab:active { transform: translateY(1px); }
.tdee-tab[aria-selected='true'] {
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

/* ---------- Form grid ---------- */
.tdee-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

@media (max-width: 540px) {
  .tdee-form-grid { grid-template-columns: 1fr; }
}

.tdee-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tdee-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

/* Inputs & selects */
.tdee-input,
.tdee-select {
  width: 100%;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 15px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.tdee-input::placeholder { color: var(--text-muted); }
.tdee-input:hover,
.tdee-select:hover { border-color: #444; }
.tdee-input:focus,
.tdee-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.18);
}
.tdee-input.is-invalid {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.15) !important;
}

/* Custom select arrow */
.tdee-select {
  padding-right: 34px;
  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='%238a8a8a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) 50%;
  background-size: 12px 8px;
}

/* RTL select arrow */
[dir='rtl'] .tdee-select {
  padding-right: 13px;
  padding-left: 34px;
  background-position: 12px 50%;
}

.tdee-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
  display: none;
}

/* ---------- Errors ---------- */
.tdee-error {
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
  display: none;
}

/* ---------- Actions ---------- */
.tdee-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.tdee-btn {
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.04s;
  white-space: nowrap;
}
.tdee-btn:hover  { opacity: 0.88; }
.tdee-btn:active { transform: translateY(1px); }
.tdee-primary { background: var(--primary); color: #fff; }
.tdee-ghost {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.tdee-ghost:hover { color: var(--text); border-color: #444; }

/* Recalc note below buttons */
p.tdee-recalc-note {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  text-align: center;
  margin: 8px 0 0;
}

/* ---------- Results panel ---------- */
.tdee-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  min-width: 0;
}

.tdee-scroll { height: 100%; overflow: auto; }

.tdee-head {
  background: #000;
  border-bottom: 2px solid var(--primary);
  padding: 16px 20px;
}
.tdee-h-title {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.tdee-h-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.tdee-body { padding: 16px 18px; }

/* ---------- Maintenance hero slab ---------- */
.tdee-maint {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 14px;
  text-align: center;
  margin-bottom: 14px;
}
.tdee-maint .big {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}
.tdee-maint .sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Activity breakdown ---------- */
.tdee-break {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 14px;
  margin-bottom: 12px;
  min-width: 0;
}
.tdee-b-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.tdee-b-rows { display: grid; gap: 3px; min-width: 0; }
.tdee-b-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.12s;
  gap: 8px;
  min-width: 0;
}
.tdee-b-row[role='button'] { cursor: pointer; }
.tdee-b-row:hover { background: var(--surface-3); }
.tdee-b-row[aria-selected='true'] {
  background: rgba(255, 106, 0, 0.12);
  border-left: 2px solid var(--primary);
  color: var(--text);
}
.tdee-b-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tdee-b-row strong { flex-shrink: 0; color: var(--text); font-weight: 800; white-space: nowrap; }

/* ---------- Goal cards ---------- */
.tdee-goals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
@media (max-width: 480px) { .tdee-goals { grid-template-columns: 1fr; } }

.goal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.06s;
  min-width: 0;
}
.goal:hover { border-color: #444; transform: translateY(-1px); }
.goal:active { transform: translateY(0); }
.goal[aria-selected='true'],
.goal.active {
  background: rgba(255, 106, 0, 0.10);
  border-color: var(--primary);
}
.goal .lbl  { color: var(--primary); font-size: 14px; font-weight: 900; margin: 0 0 4px; }
.goal .meta { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.goal .cal  { font-size: 14px; font-weight: 800; color: var(--text); }

.goal-reset {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.goal-reset:hover { color: var(--text); border-color: #444; }

/* ---------- Macros ---------- */
.tdee-mac {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 14px;
  margin-bottom: 12px;
  min-width: 0;
}
.tdee-m-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.m-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  background: var(--surface-3);
  padding: 4px;
  border-radius: 9px;
  margin-bottom: 10px;
}
.m-tab {
  border: none;
  background: transparent;
  padding: 8px 6px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-tab:hover { color: var(--text); }
.m-tab[aria-selected='true'] { background: var(--primary); color: #fff; }

.m-vals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  padding: 8px 0;
}
.m-vals .val { font-size: 22px; font-weight: 900; color: var(--primary); }
.m-vals .cap { font-size: 12px; color: var(--text-muted); }

/* ---------- Chart ---------- */
.chart-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 14px;
  margin-bottom: 12px;
  min-width: 0;
}
.chart-wrap .canvas-hold { position: relative; width: 100%; height: 230px; }
@media (max-width: 480px) { .chart-wrap .canvas-hold { height: 180px; } }

/* ---------- Note ---------- */
.tdee-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.tdee-note strong { color: var(--text-secondary); }

/* ---------- Tools (copy/share) ---------- */
.tdee-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.tdee-tool-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 9px 14px;
  border-radius: var(--radius-input);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tdee-tool-btn:hover { color: var(--text); border-color: #444; }
.tdee-tools-msg { font-size: 12px; color: var(--text-muted); margin-top: 6px; width: 100%; }

/* ---------- Focus a11y ---------- */
.tdee-wrap :focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- RTL ---------- */
[dir='rtl'] .tdee-b-row { flex-direction: row-reverse; }
[dir='rtl'] .tdee-b-row[aria-selected='true'] {
  border-left: none;
  border-right: 2px solid var(--primary);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .goal, .tdee-tab, .m-tab, .tdee-btn { transition: none !important; }
}

/* ---------- Small screen ---------- */
@media (max-width: 480px) {
  .tdee-form  { padding: 14px; }
  .tdee-body  { padding: 12px 14px; }
  .tdee-maint .big { font-size: 28px; }

  .tdee-actions {
    flex-direction: column;
  }
  .tdee-actions .tdee-btn {
    width: 100%;
    text-align: center;
  }
}
