/* ========================================
   Dashboard Funil — ADS FLOW
   Dark theme + Yellow funnel
   ======================================== */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0d1b2a;
  --accent: #f0c420;
  --accent-dark: #c9a31a;
  --accent-light: #ffe066;
  --text-primary: #e0e0e0;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6a;
  --green: #00e676;
  --red: #ff5252;
  --border: #2a2a3e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ─────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ── Logo do cliente (cinza/branco no dark) ── */

.client-logo {
  width: 104px;
  height: 104px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  flex-shrink: 0;
}

.client-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(100%) brightness(1.8) contrast(0.9);
}

.header-info h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Logo ADS FLOW (header center) ─────── */

.header-center {
  display: flex;
  align-items: center;
}

.adsflow-logo {
  height: 128px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.65;
  transition: opacity 0.2s ease;
}

.adsflow-logo:hover {
  opacity: 0.9;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Platform Selector ──────────────────── */

.platform-selector {
  display: flex;
  background: var(--bg-primary);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.platform-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.platform-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.platform-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 2px 12px rgba(240, 196, 32, 0.3);
}

.platform-btn.active svg {
  fill: var(--bg-primary);
}

/* ── Period Bar ─────────────────────────── */

.period-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.period-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.period-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.period-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.period-btn.active {
  background: rgba(240, 196, 32, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.period-custom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent);
}

.date-separator {
  color: var(--text-muted);
  font-size: 13px;
}

.date-apply {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.period-display {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Investment Banner ──────────────────── */

.investment-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 32px 0;
  padding: 16px 24px;
  background: linear-gradient(135deg, rgba(240, 196, 32, 0.1), rgba(240, 196, 32, 0.03));
  border: 1px solid rgba(240, 196, 32, 0.2);
  border-radius: var(--radius);
}

.investment-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}

.investment-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.investment-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

/* ── Funnel Container ───────────────────── */

.funnel-container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 40px 32px;
  position: relative;
}

.funnel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 0;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Funnel Step ────────────────────────── */

.funnel-step {
  display: grid;
  grid-template-columns: 0.5fr var(--funnel-width, 60%) 1fr;
  align-items: center;
  gap: 0;
  margin-bottom: 0;
  position: relative;
}

/* Bloco do funil — tamanho controlado por CSS custom properties via JS */
.funnel-block {
  position: relative;
  text-align: center;
  padding: var(--block-padding, 22px) 16px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: var(--bg-primary);
  clip-path: polygon(
    var(--indent-top) 0%,
    calc(100% - var(--indent-top)) 0%,
    calc(100% - var(--indent-bottom)) 100%,
    var(--indent-bottom) 100%
  );
  transition: all 0.25s ease;
  min-height: var(--block-min-height, 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(240, 196, 32, 0.15);
}

.funnel-block:hover {
  filter: brightness(1.1);
}

.funnel-block.editable {
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent-dark) 0%, #a8860f 100%);
}

.funnel-block.editable:hover {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.funnel-block .step-label {
  font-size: var(--label-size, 12px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.funnel-block .step-value {
  font-size: var(--value-size, 32px);
  font-weight: 800;
  line-height: 1;
}

.funnel-block .step-edit-icon {
  position: absolute;
  top: 10px;
  right: calc(var(--indent-top) + 16px);
  font-size: 14px;
  opacity: 0.5;
}

/* Editable input inside block */
.funnel-block .step-input {
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  color: var(--bg-primary);
  font-family: 'Inter', sans-serif;
  font-size: var(--input-size, 28px);
  font-weight: 800;
  text-align: center;
  width: 140px;
  padding: 4px 8px;
  outline: none;
}

.funnel-block .step-input::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

/* ── Rate Badge (between steps) ─────────── */

.funnel-rate-row {
  display: grid;
  grid-template-columns: 0.5fr var(--funnel-width, 60%) 1fr;
  align-items: center;
  margin: -2px 0;
  position: relative;
  z-index: 2;
}

.rate-badge {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.rate-badge .arrow-down {
  font-size: 10px;
  color: var(--accent);
}

/* ── Cost Metric (right side) ───────────── */

.funnel-connector {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 20px;
  gap: 10px;
}

.connector-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  position: relative;
}

.connector-line::after {
  content: '';
  position: absolute;
  right: 0;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.cost-metric {
  text-align: left;
}

.cost-metric .cost-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.cost-metric .cost-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Empty left spacer ──────────────────── */

.funnel-spacer {
  /* empty grid cell */
}

/* ── Rate Row spacers ───────────────────── */

.rate-spacer {
  /* empty */
}

/* ── Save Button (for manual fields) ────── */

.save-bar {
  display: none;
  justify-content: center;
  padding: 16px 0;
  gap: 12px;
}

.save-bar.visible {
  display: flex;
}

.save-btn {
  padding: 12px 32px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(240, 196, 32, 0.3);
}

.save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(240, 196, 32, 0.4);
}

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

.cancel-btn {
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Toast ──────────────────────────────── */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--bg-card);
  border: 1px solid var(--green);
  border-radius: 12px;
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  font-size: 18px;
}

/* ── Footer ─────────────────────────────── */

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 32px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.footer-logo {
  height: 22px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.3;
}

.footer-sep {
  margin: 0 10px;
}

/* ── Responsive ─────────────────────────── */

@media (max-width: 768px) {
  .header {
    padding: 14px 16px;
    gap: 12px;
  }

  .header-center {
    order: -1;
    width: 100%;
    justify-content: center;
  }

  .adsflow-logo {
    height: 72px;
  }

  .client-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    padding: 8px;
  }

  .header-info h1 {
    font-size: 16px;
  }

  .platform-selector {
    width: 100%;
  }

  .platform-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 13px;
  }

  .period-bar {
    padding: 10px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .period-presets {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
  }

  .period-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
  }

  .investment-banner {
    margin: 12px 16px 0;
    padding: 12px 16px;
  }

  .investment-value {
    font-size: 18px;
  }

  .funnel-container {
    padding: 0 12px 20px;
    margin: 16px auto;
  }

  /* ── Mobile funnel: block + cost inline ── */
  .funnel-step {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .funnel-spacer {
    display: none;
  }

  .funnel-block {
    clip-path: none !important;
    border-radius: 10px;
    min-height: auto !important;
    padding: 14px 16px !important;
  }

  .funnel-block .step-label {
    font-size: 11px !important;
    margin-bottom: 2px;
  }

  .funnel-block .step-value {
    font-size: 24px !important;
  }

  .funnel-block .step-edit-icon {
    top: 8px;
    right: 12px !important;
  }

  .funnel-block .step-input {
    font-size: 20px !important;
    width: 120px;
  }

  /* Cost metric appears as compact tag below block */
  .funnel-connector {
    padding: 0;
    justify-content: center;
    margin-top: -4px;
    margin-bottom: 2px;
  }

  .connector-line {
    display: none;
  }

  .cost-metric {
    text-align: center;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: var(--bg-card);
    border-radius: 0 0 8px 8px;
    border: 1px solid var(--border);
    border-top: none;
  }

  .cost-metric .cost-label {
    font-size: 10px;
    margin-bottom: 0;
  }

  .cost-metric .cost-value {
    font-size: 13px;
  }

  /* Rate badges compact */
  .funnel-rate-row {
    display: flex;
    justify-content: center;
    margin: 4px 0;
  }

  .rate-spacer {
    display: none;
  }

  .rate-badge {
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 14px;
  }
}

@media (max-width: 380px) {
  .header-left {
    gap: 10px;
  }

  .client-logo {
    width: 48px;
    height: 48px;
    padding: 6px;
  }

  .header-info h1 {
    font-size: 14px;
  }

  .funnel-block .step-value {
    font-size: 20px !important;
  }

  .funnel-block {
    padding: 12px 14px !important;
  }
}
