/* Calculadora de ROAS Favo — temas claro / escuro
   Escuro: preto + ouro
   Claro: bege quente suave (não branco puro)
*/

:root,
html[data-roi-theme="dark"] {
  color-scheme: dark;
  --roi-gold: #c5a07d;
  --roi-gold-soft: rgba(197, 160, 125, 0.2);
  --roi-border: rgba(197, 160, 125, 0.22);
  --roi-bg: #0a0a0a;
  --roi-bg-glow: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(197, 160, 125, 0.12), transparent 55%);
  --roi-surface: #141414;
  --roi-surface-2: #1a1a1a;
  --roi-text: #f5f5f0;
  --roi-muted: #9ca3af;
  --roi-success: #4ade80;
  --roi-success-bg: rgba(74, 222, 128, 0.08);
  --roi-success-border: rgba(74, 222, 128, 0.35);
  --roi-danger: #f87171;
  --roi-danger-bg: rgba(248, 113, 113, 0.08);
  --roi-danger-border: rgba(248, 113, 113, 0.35);
  --roi-thumb-ring: #0a0a0a;
  --roi-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --roi-ends: rgba(156, 163, 175, 0.55);
  --roi-font-sans: "DM Sans", system-ui, sans-serif;
  --roi-font-serif: "Playfair Display", Georgia, serif;
}

html[data-roi-theme="light"] {
  color-scheme: light;
  --roi-gold: #8f6a42;
  --roi-gold-soft: rgba(143, 106, 66, 0.18);
  --roi-border: rgba(143, 106, 66, 0.2);
  --roi-bg: #f3efe8;
  --roi-bg-glow: radial-gradient(ellipse 90% 55% at 50% -15%, rgba(197, 160, 125, 0.28), transparent 60%);
  --roi-surface: #faf7f2;
  --roi-surface-2: #efe9e0;
  --roi-text: #1c1916;
  --roi-muted: #6b635a;
  --roi-success: #1f7a45;
  --roi-success-bg: rgba(31, 122, 69, 0.08);
  --roi-success-border: rgba(31, 122, 69, 0.28);
  --roi-danger: #b42318;
  --roi-danger-bg: rgba(180, 35, 24, 0.07);
  --roi-danger-border: rgba(180, 35, 24, 0.25);
  --roi-thumb-ring: #faf7f2;
  --roi-shadow: 0 10px 32px rgba(60, 45, 30, 0.08);
  --roi-ends: rgba(107, 99, 90, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--roi-bg);
  background-image: var(--roi-bg-glow);
  background-attachment: fixed;
  color: var(--roi-text);
  font-family: var(--roi-font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.roi-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--roi-border);
  background: color-mix(in srgb, var(--roi-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.85rem 1rem;
  padding-top: max(0.85rem, env(safe-area-inset-top));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.roi-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.roi-brand {
  min-width: 0;
}

.roi-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--roi-gold);
}

.roi-title {
  margin: 0.1rem 0 0;
  font-family: var(--roi-font-serif);
  font-size: clamp(1.2rem, 4.2vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.roi-theme-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--roi-border);
  background: var(--roi-surface);
  color: var(--roi-text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--roi-shadow);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.roi-theme-btn:active {
  transform: scale(0.97);
}

.roi-theme-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--roi-gold);
  box-shadow: inset -0.28rem -0.1rem 0 0 var(--roi-surface);
}

html[data-roi-theme="light"] .roi-theme-icon {
  box-shadow: none;
  background: radial-gradient(circle at 35% 35%, #f5d9a8, var(--roi-gold));
}

.roi-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .roi-main {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 1.5rem;
    padding: 1.75rem 2rem 2.5rem;
    align-items: start;
  }

  .roi-panel {
    order: 1;
  }

  .roi-results {
    order: 2;
    position: sticky;
    top: 5.5rem;
  }
}

.roi-panel {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1.15rem 1.1rem 1.25rem;
  border: 1px solid var(--roi-border);
  border-radius: 1.1rem;
  background: var(--roi-surface);
  box-shadow: var(--roi-shadow);
}

@media (min-width: 640px) {
  .roi-panel {
    padding: 1.5rem 1.5rem 1.6rem;
    gap: 1.5rem;
  }
}

.roi-panel-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.roi-panel-title {
  margin: 0;
  font-family: var(--roi-font-serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.roi-panel-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--roi-muted);
}

.roi-slider-field {
  display: block;
}

.roi-slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.roi-slider-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--roi-muted);
}

.roi-slider-value {
  font-family: var(--roi-font-serif);
  font-size: 1.15rem;
  color: var(--roi-gold);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.15rem 0.35rem;
  margin: -0.15rem -0.35rem;
  border-radius: 0.45rem;
  cursor: text;
  text-align: right;
  line-height: 1.2;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--roi-gold) 35%, transparent);
  text-underline-offset: 0.18em;
}

.roi-slider-value:hover,
.roi-slider-value:focus-visible {
  background: color-mix(in srgb, var(--roi-gold) 14%, transparent);
  outline: none;
}

.roi-slider-value-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 5.5rem;
}

.roi-slider-edit {
  width: 7.5rem;
  max-width: 42vw;
  min-height: 40px;
  padding: 0.35rem 0.55rem;
  border-radius: 0.55rem;
  border: 1px solid var(--roi-gold);
  background: var(--roi-surface-2);
  color: var(--roi-gold);
  font-family: var(--roi-font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--roi-gold) 22%, transparent);
}

.roi-over-hint {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--roi-gold);
  cursor: pointer;
  user-select: none;
}

.roi-over-hint span {
  font-weight: 700;
}

.roi-slider-field.is-over-max .roi-slider-value {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--roi-gold) 55%, transparent);
}

.roi-slider-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: var(--roi-gold-soft);
  font-size: 16px;
  margin: 0.55rem 0;
  touch-action: none;
}

.roi-slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--roi-gold);
  border: 3px solid var(--roi-thumb-ring);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--roi-gold) 50%, transparent),
    0 4px 12px rgba(0, 0, 0, 0.18);
  cursor: grab;
  margin-top: -12px;
}

.roi-slider-field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
}

.roi-slider-field input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--roi-gold);
  border: 3px solid var(--roi-thumb-ring);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--roi-gold) 50%, transparent);
  cursor: grab;
}

.roi-slider-field input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.06);
}

.roi-slider-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--roi-ends);
}

.roi-formula {
  margin: 0.15rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--roi-border);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--roi-muted);
}

.roi-formula p {
  margin: 0 0 0.35rem;
}

.roi-formula p:last-child {
  margin-bottom: 0;
}

.roi-formula strong {
  color: var(--roi-text);
  font-weight: 600;
}

.roi-results {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.roi-hero-result {
  padding: 1.25rem 1.15rem;
  border-radius: 1.1rem;
  border: 1px solid var(--roi-success-border);
  background: var(--roi-success-bg);
  box-shadow: var(--roi-shadow);
}

.roi-hero-result.is-negative {
  border-color: var(--roi-danger-border);
  background: var(--roi-danger-bg);
}

@media (min-width: 640px) {
  .roi-hero-result {
    padding: 1.6rem 1.5rem;
  }
}

.roi-hero-value {
  margin: 0.25rem 0 0;
  font-family: var(--roi-font-serif);
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--roi-success);
  line-height: 1.05;
}

.roi-hero-result.is-negative .roi-hero-value {
  color: var(--roi-danger);
}

.roi-hero-meta {
  margin: 0.55rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--roi-muted);
}

.roi-hero-meta strong {
  color: var(--roi-text);
  font-weight: 600;
}

.roi-hero-meta .neg {
  color: var(--roi-danger);
  font-weight: 600;
}

.roi-hero-profit {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--roi-border) 80%, transparent);
  font-size: 0.9rem;
  color: var(--roi-muted);
}

.roi-hero-profit strong {
  font-family: var(--roi-font-serif);
  font-size: 1.15rem;
  color: var(--roi-success);
  font-weight: 600;
}

.roi-hero-result.is-negative .roi-hero-profit strong {
  color: var(--roi-danger);
}

.roi-stats {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 1fr 1fr;
}

.roi-stat {
  padding: 0.8rem 0.85rem;
  border: 1px solid var(--roi-border);
  border-radius: 0.85rem;
  background: var(--roi-surface);
}

.roi-stat-label {
  margin: 0;
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--roi-muted);
  font-weight: 600;
}

.roi-stat-value {
  margin: 0.3rem 0 0;
  font-family: var(--roi-font-serif);
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.roi-chart-panel {
  padding: 0.95rem 1rem 1.15rem;
  border: 1px solid var(--roi-border);
  border-radius: 1.1rem;
  background: var(--roi-surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.roi-chart-panel.is-negative {
  border-color: var(--roi-danger-border);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--roi-danger) 18%, transparent);
}

.roi-chart-head {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .roi-chart-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
}

.roi-chart-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.roi-chart-type {
  min-height: 36px;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--roi-border);
  background: var(--roi-surface-2);
  color: var(--roi-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.12s ease;
}

.roi-chart-type:active {
  transform: scale(0.96);
}

.roi-chart-type.is-active {
  background: color-mix(in srgb, var(--roi-gold) 22%, var(--roi-surface));
  border-color: color-mix(in srgb, var(--roi-gold) 55%, transparent);
  color: var(--roi-text);
}

.roi-chart-panel.is-negative .roi-chart-type.is-active {
  background: color-mix(in srgb, var(--roi-danger) 16%, var(--roi-surface));
  border-color: var(--roi-danger-border);
}

.roi-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 15.5rem;
  margin-top: 0.85rem;
}

@media (min-width: 640px) {
  .roi-chart-canvas-wrap {
    height: 17.5rem;
  }
}

.roi-chart-note {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--roi-muted);
}

@media (max-width: 380px) {
  .roi-slider-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .roi-chart-type,
  .roi-theme-btn,
  html,
  body {
    transition: none;
  }
}
