/* ═══════════════════════════════════════════════════════
   CALCULADORA DE CASHBACK — Meu Posto
   Corporate professional theme
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --primary-dark: #020617;
  
  --accent: #0ea5e9;
  --accent-light: #38bdf8;
  --accent-glow: rgba(14, 165, 233, 0.15);
  
  --success: #10b981;
  --success-light: #34d399;
  
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --surface-muted: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  --border: #e2e8f0;
  --border-focus: #0ea5e9;
  
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  background: var(--primary);
  padding: 40px 24px 48px;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: linear-gradient(135deg, transparent, rgba(14, 165, 233, 0.1));
  pointer-events: none;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.logo-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-inverse);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.header-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Main layout ── */
.calculator-container {
  max-width: 1200px;
  margin: -32px auto 0;
  padding: 0 24px 60px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  width: 36px;
  height: 36px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Input groups ── */
.input-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  margin-top: 24px;
}

.input-group-label:first-of-type {
  margin-top: 0;
}

.group-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 4px;
}

.group-badge.primary {
  background: #dbeafe;
  color: #1d4ed8;
}

.group-badge.secondary {
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.group-badge.advanced {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* ── Toggle buttons ── */
.toggle-defaults {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.toggle-defaults:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.toggle-chevron {
  font-size: 0.65rem;
  transition: transform 0.3s ease;
}

.toggle-defaults[aria-expanded="true"] .toggle-chevron {
  transform: rotate(180deg);
}

/* ── Collapsible panels ── */
.defaults-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 0;
  margin-bottom: 0;
}

.defaults-panel.open {
  max-height: 300px;
  opacity: 1;
  margin-bottom: 16px;
}

/* ── Input fields ── */
.input-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

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

.input-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-prefix {
  font-size: 1rem;
  margin-right: 8px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.input-suffix {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
  flex-shrink: 0;
}

.input-field input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 0;
  font-family: inherit;
  -moz-appearance: textfield;
}

.input-field.compact input {
  padding: 10px 0;
  font-size: 0.9rem;
}

.input-field input::-webkit-outer-spin-button,
.input-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Calculate button ── */
.btn-calculate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  margin-top: 16px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-inverse);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
}

.btn-calculate:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-calculate:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

.btn-calculate:hover .btn-icon {
  transform: translateX(3px);
}

/* ── Results section ── */
.card-outputs {
  display: flex;
  flex-direction: column;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Result cards ── */
.result-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  transition: var(--transition);
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.result-card.has-value {
  border-color: var(--accent);
}

.result-card.highlight-card {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-color: #bae6fd;
}

.result-card.savings-card {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-color: #a7f3d0;
}

.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.highlight-card .result-value {
  color: #0369a1;
}

.savings-card .result-value {
  color: #047857;
}

.result-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Pulse animation ── */
@keyframes result-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.result-card.pop {
  animation: result-pop 0.3s ease;
}

/* ── Breakdown section ── */
.breakdown-section {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.breakdown-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breakdown-icon {
  font-size: 0.9rem;
}

.breakdown-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.breakdown-row:hover {
  background: rgba(0, 0, 0, 0.02);
}

.breakdown-row.sub {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-top: 4px;
}

.breakdown-row.total {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  margin-top: 8px;
}

.breakdown-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.breakdown-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.breakdown-value.green {
  color: var(--success);
}

/* ── Comparison bars ── */
.comparison-bar-section {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
}

.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 90px;
  align-items: center;
  gap: 12px;
}

.bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

.bar-track {
  height: 24px;
  background: var(--surface-muted);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  border-radius: 12px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-desconto {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.bar-cashback {
  background: linear-gradient(90deg, var(--success), var(--success-light));
}

.bar-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .calculator-container {
    grid-template-columns: 1fr;
    max-width: 640px;
  }
  
  .header-title {
    font-size: 1.75rem;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 32px 20px 40px;
  }
  
  .header-title {
    font-size: 1.5rem;
  }
  
  .calculator-container {
    padding: 0 16px 40px;
    margin-top: -24px;
  }
  
  .card {
    padding: 20px;
  }
  
  .input-row {
    grid-template-columns: 1fr;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .bar-row {
    grid-template-columns: 80px 1fr 70px;
    gap: 8px;
  }
  
  .result-value {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.25rem;
  }
  
  .card {
    padding: 16px;
    border-radius: 10px;
  }
  
  .result-card {
    padding: 14px;
  }
  
  .result-value {
    font-size: 1.1rem;
  }
  
  .breakdown-section,
  .comparison-bar-section {
    padding: 14px;
  }
  
  .bar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  
  .bar-label {
    text-align: left;
  }
}