/* ============================================
   ROX DASHBOARD — Premium Dark Mode Stylesheet
   Design Tokens: Deep Navy + Cyan Electric + Glass
   ============================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Background */
  --bg-deep: #020813;
  --bg-card: rgba(7, 17, 32, 0.75);
  --bg-card-hover: rgba(10, 24, 48, 0.85);
  --bg-header: rgba(2, 8, 19, 0.92);

  /* Accent */
  --accent-cyan: #00D2FF;
  --accent-cyan-glow: rgba(0, 210, 255, 0.15);
  --accent-cyan-subtle: rgba(0, 210, 255, 0.08);

  /* Status */
  --green: #10B981;
  --green-glow: rgba(16, 185, 129, 0.15);
  --yellow: #FBBF24;
  --yellow-glow: rgba(251, 191, 36, 0.15);
  --red: #EF4444;
  --red-glow: rgba(239, 68, 68, 0.15);

  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #475569;

  /* Borders */
  --border-glass: rgba(0, 210, 255, 0.12);
  --border-subtle: rgba(148, 163, 184, 0.08);

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 40px rgba(0, 210, 255, 0.03);
  --shadow-glow: 0 0 20px rgba(0, 210, 255, 0.1);

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cosmic background effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 80% 20%, rgba(0, 210, 255, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, rgba(0, 100, 200, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(2, 8, 19, 1) 0%, var(--bg-deep) 100%);
  z-index: -1;
  pointer-events: none;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  padding: var(--space-md) var(--space-xl);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-brand img {
  height: 40px;
  width: auto;
  filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.3));
}

.header-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.header-client {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-period {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Health Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge--stable {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge--warning {
  background: var(--yellow-glow);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge--critical {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* --- Main Container --- */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-xl);
}

/* --- Section Titles --- */
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent-cyan);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* --- Meta Progress Bar --- */
.meta-progress-section {
  margin-bottom: var(--space-2xl);
}

.meta-progress-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: var(--shadow-card);
}

.meta-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.meta-progress-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.meta-progress-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.meta-progress-value span {
  color: var(--text-muted);
  font-weight: 400;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent-cyan), #00F5A0);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.4);
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 100px;
  filter: blur(4px);
}

.meta-progress-percentage {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-top: 6px;
}

/* --- Metric Cards Grid --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(0, 210, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  opacity: 0;
  transition: var(--transition);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
  background: var(--accent-cyan-subtle);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

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

.metric-value--cyan {
  color: var(--accent-cyan);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Charts Section --- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
}

.chart-card--full {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* --- Channels Table --- */
.table-section {
  margin-bottom: var(--space-2xl);
}

.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody td {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.data-table tbody tr:hover td {
  background: var(--accent-cyan-subtle);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.channel-name {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.channel-dot--google { background: #4285F4; }
.channel-dot--meta { background: #0668E1; }
.channel-dot--whatsapp { background: #25D366; }

/* --- ROI Highlight --- */
.roi-section {
  margin-bottom: var(--space-2xl);
}

.roi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-md);
}

.roi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: var(--transition);
}

.roi-card:hover {
  border-color: rgba(0, 210, 255, 0.25);
  box-shadow: var(--shadow-glow);
}

.roi-card--highlight {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.08), rgba(0, 245, 160, 0.05));
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.roi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.roi-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
}

.roi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.footer-brand img {
  height: 20px;
  opacity: 0.5;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  .header-info {
    align-items: center;
  }

  .main {
    padding: var(--space-md);
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 1.4rem;
  }

  .roi-value {
    font-size: 1.8rem;
  }

  .metric-card {
    padding: var(--space-md);
  }

  .diagnostic-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   EDIT MODAL (ADMIN)
   ============================================ */
.edit-modal {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  color: var(--text-primary);
  width: 90%;
  max-width: 800px;
  margin: auto;
  padding: 0;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 210, 255, 0.2);
  backdrop-filter: blur(20px);
}
.edit-modal::backdrop {
  background: rgba(2, 8, 19, 0.85);
  backdrop-filter: blur(5px);
}
.modal-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}
.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.2rem;
  color: var(--accent-cyan);
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-body {
  padding: var(--space-xl);
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}
.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-glass);
  text-align: right;
  background: var(--bg-card);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.form-group input, .form-group textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: white;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
}
.form-section-title {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--accent-cyan);
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 5px;
  margin-top: 10px;
}
.btn-primary:hover {
  filter: brightness(1.2);
}

/* ============================================
   NEW SECTIONS: Diagnostics, Benchmarks, Agent
   ============================================ */

/* --- Diagnostic Section --- */
.diagnostic-section {
  margin-bottom: var(--space-2xl);
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.diagnostic-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.diagnostic-card:hover {
  transform: translateY(-2px);
}

.diagnostic-card--gargalo {
  border: 1px solid rgba(251, 191, 36, 0.2);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.04), var(--bg-card));
}

.diagnostic-card--gargalo::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--yellow), transparent);
}

.diagnostic-card--recomendacao {
  border: 1px solid rgba(0, 210, 255, 0.2);
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.04), var(--bg-card));
}

.diagnostic-card--recomendacao::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
}

.diagnostic-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.diagnostic-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.diagnostic-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.6;
}

/* --- Warning State for Metrics --- */
.metric-value--warn {
  color: var(--yellow);
}

/* --- Benchmark Status Badges --- */
.bench-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.bench-status--ok {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.bench-status--fail {
  background: var(--yellow-glow);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.25);
}
