/* ═══════════════════════════════════════
   Marketing Funnel Dashboard — Styles
   ═══════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-body: #0c0f1a;
  --bg-card: #131829;
  --bg-card-hover: #1a1f36;
  --border: #1a1f36;
  --border-light: #252b45;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --green: #34d399;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --red: #ef4444;
  --purple: #a78bfa;
  --pink: #f472b6;
  --amber: #f59e0b;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --transition: 0.2s ease;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Banners ── */
.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
}

.banner--red {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}

.banner--amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
}

.banner__icon {
  font-size: 16px;
  flex-shrink: 0;
}

.banner code {
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header__right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

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

.header__meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Status Dots ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot--ok {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.status-dot--expired {
  background: var(--red);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(239,68,68,0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 12px rgba(239,68,68,0.8); }
}

.status-label {
  margin-right: 8px;
}

/* ── Form Controls ── */
.date-select {
  background: var(--bg-body);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.date-select:hover,
.date-select:focus {
  border-color: var(--blue);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--blue);
  color: #0c0f1a;
}

.btn--primary:hover:not(:disabled) {
  background: #93bbfd;
  transform: translateY(-1px);
}

.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: #0c0f1a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Main ── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 20px;
}

.empty-state__icon {
  opacity: 0.5;
}

.empty-state__text {
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab--active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: block;
}

/* ── Funnel Visualization ── */
.funnel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  padding: 32px 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.funnel__stage {
  max-width: 100%;
  min-width: 120px;
  transition: width 0.5s ease;
}

.funnel__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: var(--radius);
  gap: 12px;
}

.funnel__stage--social .funnel__bar {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.funnel__stage--consult .funnel__bar {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.funnel__stage--tenant .funnel__bar {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.funnel__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.funnel__stage--social .funnel__label { color: var(--blue); }
.funnel__stage--consult .funnel__label { color: var(--yellow); }
.funnel__stage--tenant .funnel__label { color: var(--green); }

.funnel__count {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.funnel__pct {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.funnel__arrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.funnel__conv {
  font-weight: 500;
}

/* ── Summary Cards ── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card--stat {
  text-align: center;
  padding: 24px 16px;
}

.card--highlight-red {
  text-align: center;
  padding: 24px;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.card__value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.card__value--blue { color: var(--blue); }
.card__value--yellow { color: var(--yellow); }
.card__value--green { color: var(--green); }
.card__value--red { color: var(--red); }
.card__value--default { color: var(--text-primary); }

.card__label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Grid Layouts ── */
.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid--2col {
  grid-template-columns: repeat(2, 1fr);
}

/* ── Chart Wrappers ── */
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 300px;
}

.chart-wrap--sm {
  min-height: 200px;
  max-width: 280px;
  margin: 0 auto;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

.data-table tfoot td {
  border-top: 2px solid var(--border-light);
  border-bottom: none;
  color: var(--text-primary);
}

.row--other {
  background: rgba(167, 139, 250, 0.08);
}

.row--other:hover {
  background: rgba(167, 139, 250, 0.12) !important;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.badge--purple {
  background: rgba(167, 139, 250, 0.2);
  color: var(--purple);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

/* ── Card spacing between panels ── */
.tab-panel .card + .card {
  margin-top: 16px;
}

.tab-panel .card--highlight-red {
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */

@media (max-width: 1024px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .header__title {
    font-size: 17px;
  }

  .header__right {
    width: 100%;
    justify-content: space-between;
  }

  .header__status {
    font-size: 12px;
  }

  .main {
    padding: 16px;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .grid--2col {
    grid-template-columns: 1fr;
  }

  .funnel__count {
    font-size: 18px;
  }

  .funnel__bar {
    padding: 12px 14px;
  }

  .card__value {
    font-size: 26px;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .header__controls {
    width: 100%;
  }

  .date-select {
    flex: 1;
  }

  .btn {
    flex: 1;
    justify-content: center;
  }
}
