/* ============================================================
   PROJECT MARGIN CALCULATOR — style.css
   Primary: #6A0BE4 | Dark: #5a09c4 | Light: #f0ebff | Lightest: #f7f4ff
   ============================================================ */

:root {
  --p: #6A0BE4;
  --p-h: #5a09c4;
  --p-lt: #f0ebff;
  --p-llt: #f7f4ff;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --navy: #1a1a2e;
  --navy-2: #16213e;
  --text: #0f0a1e;
  --text-2: #4b4b6a;
  --text-3: #8888aa;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-2: #f8f8fc;
  --shadow-sm: 0 1px 3px rgba(15,10,30,.06);
  --shadow-md: 0 4px 20px rgba(106,11,228,.10), 0 1px 4px rgba(15,10,30,.06);
  --shadow-lg: 0 8px 40px rgba(106,11,228,.14);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --font: 'Inter', sans-serif;
  --ease: cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--bg-2); line-height: 1.6; }
a { text-decoration: none; color: inherit; }

/* ── TOOL HEADER (dark navy bar) ── */
#tool-header {
  background: var(--navy);
  padding: 40px 24px 44px;
  position: relative;
  overflow: hidden;
}
#tool-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 55% 80% at 70% 120%, rgba(106,11,228,.55) 0%, transparent 60%);
  pointer-events: none;
}
#tool-header::after {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: rgba(106,11,228,.18);
  pointer-events: none;
}
.header-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.header-text h1 {
  font-size: clamp(20px, 2.8vw, 32px);
  font-weight: 800;
  color: #fff;
  letter-spacing: -.4px;
  line-height: 1.15;
  margin-bottom: 8px;
}
.header-text h1 span { color: #c4b5fd; }
.header-text p { font-size: 14.5px; color: rgba(255,255,255,.65); max-width: 520px; }
.header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.hbadge {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.8);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
}

/* ── MAIN 2-COL LAYOUT ── */
#calc-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 60px;
  display: grid;
  grid-template-columns: 45% 1fr;
  gap: 24px;
  align-items: flex-start;
}

/* ── LEFT: INPUT PANEL ── */
#input-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.ip-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.ip-section:last-of-type { border-bottom: none; }
.ip-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.ip-section-label .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--p);
  flex-shrink: 0;
}
.ip-section-label h3 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--p);
}
.form-row { display: grid; gap: 12px; margin-bottom: 0; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  pointer-events: none;
}
.input-suffix {
  position: absolute;
  right: 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  pointer-events: none;
}
.input-wrap input {
  width: 100%;
  padding: 9px 11px 9px 26px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.input-wrap.has-suffix input { padding-right: 38px; padding-left: 11px; }
.input-wrap input:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(106,11,228,.1);
}
.input-wrap input::placeholder { color: var(--text-3); font-weight: 400; }
.input-wrap.large input {
  font-size: 18px;
  font-weight: 700;
  padding: 11px 11px 11px 28px;
}
.input-wrap.large .input-prefix { font-size: 16px; }
.hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }

#calc-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px 24px;
  padding: 14px;
  border: none;
  border-radius: var(--r-md);
  background: var(--p);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(106,11,228,.35);
  transition: background .2s, transform .15s, box-shadow .2s;
  letter-spacing: .3px;
}
#calc-btn:hover { background: var(--p-h); box-shadow: 0 6px 24px rgba(106,11,228,.45); }
#calc-btn:active { transform: scale(.98); }

/* ── RIGHT: RESULTS PANEL ── */
#results-panel {
  position: sticky;
  top: 24px;
}

.results-empty {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-xl);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-3);
}
.results-empty svg { opacity: .3; margin-bottom: 12px; }
.results-empty p { font-size: 13px; }

/* Big metric hero */
.metric-hero {
  background: var(--navy);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 28px 24px 24px;
  position: relative;
  overflow: hidden;
}
.metric-hero::before {
  content: '';
  position: absolute;
  bottom: -40px; right: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(106,11,228,.35);
  pointer-events: none;
}
.metric-hero-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin-bottom: 4px;
}
.metric-hero-value {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  color: #a78bfa;
  letter-spacing: -1px;
  line-height: 1;
  position: relative;
  z-index: 1;
}
.metric-hero-value.positive { color: #6ee7b7; }
.metric-hero-value.negative { color: #fca5a5; }
.metric-hero-sub {
  font-size: 12px;
  color: rgba(255,255,255,.45);
  margin-top: 4px;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 14px;
  position: relative;
  z-index: 1;
}
.status-badge.excellent { background: rgba(16,185,129,.2); color: #6ee7b7; }
.status-badge.good { background: rgba(106,11,228,.3); color: #c4b5fd; }
.status-badge.low { background: rgba(245,158,11,.2); color: #fcd34d; }
.status-badge.at-risk { background: rgba(239,68,68,.2); color: #fca5a5; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 4 metric grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.metric-tile {
  background: var(--bg);
  padding: 16px 18px;
}
.metric-tile-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 4px;
}
.metric-tile-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}
.metric-tile-value.accent { color: var(--p); }
.metric-tile-value.positive { color: var(--success); }
.metric-tile-value.negative { color: var(--danger); }
.metric-tile-delta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Bar chart */
.breakdown-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  padding: 20px 20px 18px;
}
.breakdown-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 14px;
}
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row-label { width: 110px; font-size: 12px; font-weight: 500; color: var(--text-2); flex-shrink: 0; }
.bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .6s var(--ease);
  position: relative;
}
.bar-fill.revenue { background: linear-gradient(90deg, var(--p), #8b5cf6); }
.bar-fill.cost { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.profit { background: linear-gradient(90deg, #10b981, #34d399); }
.bar-fill.loss { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-row-val { width: 90px; font-size: 11.5px; font-weight: 700; color: var(--text); text-align: right; flex-shrink: 0; }

/* Improvement section */
.improvement-section {
  background: var(--p-llt);
  border: 1px solid var(--p-lt);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  padding: 16px 20px 18px;
}
.improvement-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--p);
  margin-bottom: 10px;
}
.improvement-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: var(--r-sm);
  border: 1px solid var(--p-lt);
  margin-bottom: 8px;
}
.improvement-row:last-child { margin-bottom: 0; }
.improvement-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--p-lt);
  color: var(--p);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 1px;
}
.improvement-text strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1px;
}
.improvement-text span {
  font-size: 11.5px;
  color: var(--text-2);
}
.improvement-text span em {
  color: var(--p);
  font-style: normal;
  font-weight: 700;
}

/* ── CONTENT SECTION ── */
#content-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}
.content-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.content-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: -.3px;
}
.content-card p { font-size: 14.5px; color: var(--text-2); line-height: 1.75; margin-bottom: 12px; }
.content-card p:last-child { margin-bottom: 0; }
.content-card ul, .content-card ol { padding-left: 1.4em; }
.content-card li { font-size: 14.5px; color: var(--text-2); line-height: 1.75; margin-bottom: 6px; }

.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.formula-box {
  background: var(--p-llt);
  border: 1px solid var(--p-lt);
  border-radius: var(--r-md);
  padding: 16px;
}
.formula-box h4 { font-size: 12px; font-weight: 700; color: var(--p); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 6px; }
.formula-box code { font-size: 12.5px; color: var(--text); font-family: 'Courier New', monospace; line-height: 1.5; display: block; }

/* FAQ accordion */
.faq-list { margin-top: 8px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-q {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 15px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background .18s;
}
.faq-q:hover { background: var(--p-llt); }
.faq-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--p-lt);
  color: var(--p);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  transition: transform .25s var(--ease), background .2s;
}
.faq-item.open .faq-icon { transform: rotate(45deg); background: var(--p); color: #fff; }
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s var(--ease), padding .25s;
  padding: 0 18px;
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.75;
}
.faq-item.open .faq-a { max-height: 400px; padding: 0 18px 16px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  #calc-wrap { grid-template-columns: 1fr; }
  #results-panel { position: static; }
  .form-row.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  #tool-header { padding: 28px 16px 32px; }
  #calc-wrap { padding: 20px 16px 40px; }
  #content-section { padding: 0 16px 60px; }
  .content-card { padding: 24px 18px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
