/* FMS Dashboard v3.0.2 — Fight Music Show Command Center
 * Brand: black #000 + gold #faad0d (from fightmusicshow.com.br) + accent red #dc3232.
 * Design system reference: dark/cadence-landing-19 structure (deep blacks, minimal chrome, gentle accent glows).
 */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  /* surfaces */
  --bg:           #000000;
  --bg-elev:      #07070A;
  --surface:      #0E0E14;
  --surface-2:    #15151D;
  --surface-hover:#1C1C26;
  --border:       #232330;
  --border-light: #33334A;

  /* text */
  --text:           #FAFAFA;
  --text-secondary: #B8B8C4;
  --text-muted:     #6E6E80;

  /* brand */
  --gold:        #FAAD0D;       /* primário FMS */
  --gold-2:      #FFC845;
  --gold-glow:   rgba(250,173,13,0.18);
  --gold-deep:   #B47C00;
  --red:         #DC3232;
  --red-glow:    rgba(220,50,50,0.18);

  /* legacy aliases (compat with existing app.js) */
  --accent:        var(--gold);
  --accent-glow:   var(--gold-glow);
  --orange:        var(--gold-2);
  --orange-glow:   var(--gold-glow);
  --green:         #22C55E;
  --green-glow:    rgba(34,197,94,0.18);
  --yellow:        var(--gold);
  --yellow-glow:   var(--gold-glow);
  --blue:          #3B82F6;
  --blue-glow:     rgba(59,130,246,0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -200px, rgba(250,173,13,0.06), transparent 60%),
    radial-gradient(800px 400px at 20% 110%, rgba(220,50,50,0.04), transparent 60%),
    var(--bg);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Safe area for notched phones */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); }

input[type="date"] { color-scheme: dark; font-family: 'Inter', sans-serif; }

/* === TYPOGRAPHY === */
.brand-title {
  font-family: 'Bebas Neue', 'Inter', sans-serif;
  font-weight: 400; letter-spacing: 0.02em;
}
h1, h2, h3, h4 { font-family: 'Inter', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
.kpi-value, .metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; letter-spacing: -0.025em;
}

/* === HEADER LOGO === */
.fms-logo {
  height: 36px; width: auto;
  filter: drop-shadow(0 0 18px var(--gold-glow));
}
@media (max-width: 640px) { .fms-logo { height: 28px; } }

/* === ROAS HERO (compact top row) === */
.roas-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  transition: border-color .2s ease;
}
.roas-hero-card:hover { border-color: var(--gold-deep); }
.roas-hero-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 6px;
}
.roas-hero-tag {
  font-size: 8px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-secondary);
  text-transform: lowercase; letter-spacing: 0.02em; font-weight: 500;
}
.roas-hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800; font-size: 1.6rem; line-height: 1.1;
  letter-spacing: -0.03em;
}
.roas-hero-value .roas-hero-x { font-size: 0.7em; color: var(--text-muted); margin-left: 1px; }
.roas-hero-sub { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.roas-hero-meta { background: var(--bg-elev); }

@media (min-width: 768px) {
  .roas-hero-card { padding: 10px 14px; }
  .roas-hero-label { font-size: 10px; }
  .roas-hero-value { font-size: 2rem; }
  .roas-hero-sub { font-size: 11px; }
}

/* === PLATFORM CARDS (compact, Meta + Google) === */
.platform-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color .2s ease;
}
.platform-card:hover { border-color: var(--border-light); }
.platform-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text);
}
.platform-source {
  font-size: 9px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-muted); text-transform: lowercase;
}
.platform-revenue {
  font-size: 12px; color: var(--text-secondary); font-weight: 500;
}
.platform-meta {
  font-size: 10px; color: var(--text-muted); margin-top: 3px;
}
@media (min-width: 768px) {
  .platform-card { padding: 10px 14px; }
  .platform-label { font-size: 12px; }
}

/* === KPI CARDS === */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  position: relative; overflow: hidden;
  transition: transform .25s ease, border-color .25s ease, background .25s ease;
}
@media (min-width: 768px) { .kpi-card { padding: 14px 16px; border-radius: 12px; } }
.kpi-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(250,173,13,0) 0%, rgba(250,173,13,0.04) 100%);
  opacity: 0; transition: opacity .25s ease;
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--gold-deep); }
.kpi-card:hover::before { opacity: 1; }
.kpi-card .kpi-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
}
.kpi-card .kpi-value { font-size: 1.1rem; color: var(--text); line-height: 1.2; }
.kpi-card .kpi-sub { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
@media (min-width: 768px) {
  .kpi-card .kpi-label { font-size: 10px; margin-bottom: 6px; letter-spacing: 0.08em; }
  .kpi-card .kpi-value { font-size: 1.45rem; }
  .kpi-card .kpi-sub { font-size: 11px; }
}
.kpi-card.is-positive .kpi-value { color: var(--gold); }

/* === ANIMATIONS === */
@keyframes countUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.kpi-card { animation: countUp 0.35s ease-out both; }
.kpi-card:nth-child(1) { animation-delay: .04s; }
.kpi-card:nth-child(2) { animation-delay: .08s; }
.kpi-card:nth-child(3) { animation-delay: .12s; }
.kpi-card:nth-child(4) { animation-delay: .16s; }
.kpi-card:nth-child(5) { animation-delay: .20s; }
.kpi-card:nth-child(6) { animation-delay: .24s; }
.kpi-card:nth-child(7) { animation-delay: .28s; }

/* === PANELS / SURFACES === */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.panel-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.panel-title::before {
  content: ''; width: 14px; height: 2px; background: var(--gold); border-radius: 2px;
}

/* === SEMAPHORE === */
.semaphore-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; animation: pulse-dot 2s ease-in-out infinite;
}
.semaphore-dot.green  { background: var(--green); box-shadow: 0 0 10px var(--green-glow); }
.semaphore-dot.yellow { background: var(--gold);  box-shadow: 0 0 10px var(--gold-glow); }
.semaphore-dot.red    { background: var(--red);   box-shadow: 0 0 10px var(--red-glow); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* === BADGES === */
.badge-winner         { background: var(--green-glow); color: var(--green); border: 1px solid rgba(34,197,94,0.35); }
.badge-average        { background: var(--gold-glow);  color: var(--gold);  border: 1px solid rgba(250,173,13,0.35); }
.badge-underperformer { background: var(--red-glow);   color: var(--red);   border: 1px solid rgba(220,50,50,0.35); }
.badge-pending        { background: rgba(110,110,128,0.12); color: var(--text-muted); border: 1px solid var(--border); }

/* === FUNNEL v2 — preserved from v3.0.1 === */
.fv2-wrap { width: 100%; padding: 4px 0; }
.fv2-stage { display: flex; align-items: center; gap: 10px; opacity: 0; transform: translateX(-6px); animation: fv2-in 0.35s ease-out forwards; }
.fv2-stage:nth-child(1) { animation-delay: 0.05s; }
.fv2-stage:nth-child(3) { animation-delay: 0.13s; }
.fv2-stage:nth-child(5) { animation-delay: 0.21s; }
.fv2-stage:nth-child(7) { animation-delay: 0.29s; }
.fv2-stage:nth-child(9) { animation-delay: 0.37s; }
@keyframes fv2-in { to { opacity: 1; transform: translateX(0); } }
.fv2-label { flex: 0 0 72px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); text-align: right; white-space: nowrap; padding-right: 4px; }
.fv2-bar-track { flex: 1 1 auto; position: relative; height: 36px; }
.fv2-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; width: 0%; transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1); display: flex; align-items: center; padding: 0 10px; gap: 8px; overflow: hidden; min-width: 2px; }
.fv2-bar-fill::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,0.3); border-radius: 6px 0 0 6px; }
.fv2-bar-value { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; letter-spacing: -0.02em; color: #fff; white-space: nowrap; position: relative; }
.fv2-bar-sub { font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.6); white-space: nowrap; position: relative; }
.fv2-stat { flex: 0 0 52px; text-align: left; }
.fv2-stat-pct { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.fv2-stat-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px; }
.fv2-drop { display: flex; align-items: center; gap: 10px; height: 22px; opacity: 0; animation: fv2-in 0.35s ease-out forwards; }
.fv2-drop:nth-child(2) { animation-delay: 0.09s; }
.fv2-drop:nth-child(4) { animation-delay: 0.17s; }
.fv2-drop:nth-child(6) { animation-delay: 0.25s; }
.fv2-drop:nth-child(8) { animation-delay: 0.33s; }
.fv2-drop-spacer { flex: 0 0 72px; }
.fv2-drop-line { flex: 1 1 auto; display: flex; align-items: center; gap: 6px; }
.fv2-drop-tick { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.fv2-drop-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 4px; background: rgba(220,50,50,0.1); border: 1px solid rgba(220,50,50,0.25); font-size: 10px; font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--red); white-space: nowrap; }
.fv2-drop-badge.drop-low { background: rgba(250,173,13,0.08); border-color: rgba(250,173,13,0.25); color: var(--gold); }
.fv2-drop-count { font-size: 10px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.fv2-drop-right { flex: 0 0 52px; }
.fv2-empty { text-align: center; padding: 32px 0; color: var(--text-muted); font-size: 13px; }

/* === TAGS === */
.tag-meta    { background: var(--blue-glow);   color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }
.tag-google  { background: var(--gold-glow);   color: var(--gold);   border: 1px solid rgba(250,173,13,0.35); }
.tag-organic { background: var(--green-glow);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.tag-none    { background: rgba(110,110,128,0.15); color: var(--text-muted); border: 1px solid rgba(110,110,128,0.3); }
.tag-tiktok  { background: rgba(255,255,255,0.06); color: #FFF; border: 1px solid rgba(255,255,255,0.2); }

/* === TABLE === */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { position: sticky; top: 0; background: var(--surface); z-index: 1; color: var(--text-muted); font-weight: 600; font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text); white-space: nowrap; }
@media (min-width: 768px) {
  .data-table th { font-size: 10px; letter-spacing: 0.08em; padding: 10px 14px; }
  .data-table td { font-size: 13px; padding: 10px 14px; }
}
.data-table tr:hover td { background: var(--surface-hover); }
.data-table .num { font-family: 'JetBrains Mono', monospace; font-weight: 600; }

/* === TAB ACTIVE === */
.tab-active { position: relative; color: var(--text) !important; }
.tab-active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-2) 100%);
  border-radius: 2px 2px 0 0;
}

/* === SORT BUTTON ACTIVE === */
.active-sort { color: var(--gold) !important; border-color: var(--gold) !important; background: var(--gold-glow); }

/* === CTA / BUTTONS === */
.btn-primary {
  background: var(--gold); color: #000; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--gold-2); transition: filter .15s ease, transform .15s ease;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  padding: 6px 12px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--border); transition: all .15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--gold-deep); }

/* === CREATIVE GALLERY CARDS — Mobile First === */
.creative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  display: flex; flex-direction: column;
}
.creative-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-deep);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 0 0 1px var(--gold-glow);
}
.creative-card.is-winner         { border-color: rgba(34,197,94,0.45); }
.creative-card.is-underperformer { border-color: rgba(220,50,50,0.45); }

.creative-thumb {
  position: relative; aspect-ratio: 1 / 1; background: linear-gradient(135deg, #0E0E14 0%, #15151D 100%);
  overflow: hidden; cursor: pointer;
}
.creative-thumb::after {
  /* Skeleton shimmer while image loads */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(250,173,13,0.06) 50%, transparent 100%);
  animation: shimmer 1.8s ease-in-out infinite;
  z-index: 0; pointer-events: none;
}
.creative-thumb img {
  position: relative; z-index: 1;
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s ease;
  background: var(--bg-elev);
}
.creative-thumb img[src]:not([src=""]) ~ * { } /* no-op */
.creative-thumb:hover img { transform: scale(1.04); }
@keyframes shimmer {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}
.creative-thumb-empty {
  position: relative; z-index: 1;
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; text-align: center; padding: 8px;
}
.creative-thumb-ig-overlay {
  position: absolute; bottom: 6px; right: 6px; z-index: 3;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 6px; border-radius: 6px;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 9px; font-weight: 600; color: #fff; text-decoration: none;
  transition: background .15s ease, transform .15s ease;
  line-height: 1;
}
.creative-thumb-ig-overlay:hover {
  background: linear-gradient(135deg, #833AB4 0%, #E1306C 100%);
  transform: scale(1.05);
}
.creative-thumb-ig-overlay span { display: none; }
@media (min-width: 768px) { .creative-thumb-ig-overlay span { display: inline; } }
.creative-thumb-quality-badge {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  padding: 2px 6px; border-radius: 5px; font-size: 8px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
@media (min-width: 768px) { .creative-thumb-quality-badge { font-size: 9px; padding: 3px 8px; } }

.creative-card-body {
  padding: 8px 10px;
  flex: 1; display: flex; flex-direction: column; gap: 6px;
}
@media (min-width: 768px) { .creative-card-body { padding: 12px 14px; gap: 10px; } }

.creative-name {
  font-size: 11px; font-weight: 700; color: var(--text);
  line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 768px) { .creative-name { font-size: 13px; line-height: 1.3; } }

.creative-meta {
  font-size: 10px; color: var(--text-muted);
  display: flex; gap: 4px; flex-wrap: wrap;
}
.creative-meta .meta-chip {
  padding: 1px 5px; border-radius: 3px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 9px; color: var(--text-secondary);
  white-space: nowrap;
}
@media (min-width: 768px) {
  .creative-meta { font-size: 11px; gap: 8px; }
  .creative-meta .meta-chip { padding: 2px 7px; font-size: 10px; }
}

.creative-metrics {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 4px; padding-top: 6px; border-top: 1px solid var(--border);
}
@media (min-width: 480px) { .creative-metrics { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px) { .creative-metrics { grid-template-columns: repeat(4, 1fr); padding-top: 10px; } }

.metric-cell { display: flex; flex-direction: column; gap: 1px; }
.metric-cell .label { font-size: 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-cell .value { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text); }
.metric-cell.is-good .value { color: var(--green); }
.metric-cell.is-bad .value  { color: var(--red); }
@media (min-width: 768px) {
  .metric-cell .label { font-size: 9px; }
  .metric-cell .value { font-size: 13px; }
}

.creative-actions {
  display: flex; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border);
}
.creative-actions a {
  flex: 1; text-align: center; padding: 5px 6px; border-radius: 6px;
  font-size: 10px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--border); color: var(--text-secondary);
  transition: all .15s ease;
}
@media (min-width: 768px) {
  .creative-actions { gap: 6px; padding-top: 8px; }
  .creative-actions a { padding: 6px 8px; font-size: 11px; border-radius: 8px; }
}
.creative-actions a:hover { border-color: var(--gold); color: var(--gold); }
.creative-actions a.ig-link {
  color: #fff; font-weight: 700;
  background: linear-gradient(135deg, #833AB4 0%, #E1306C 50%, #FFD600 100%);
  border-color: transparent;
}
.creative-actions a.ig-link:hover { filter: brightness(1.1); color: #fff; }

/* === MODAL === */
.modal-overlay { backdrop-filter: blur(6px); background: rgba(0,0,0,0.7); }
.modal-content { animation: modalIn 0.22s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal-content video, .modal-content img { max-width: 100%; max-height: 80vh; border-radius: 10px; }

/* === CHARTS responsive === */
.apexcharts-canvas, .apexcharts-svg { max-width: 100% !important; }
[id^="chart-"], #funnel, #funnel-trafego { min-height: 200px; width: 100%; overflow: hidden; }
@media (max-width: 640px) {
  [id^="chart-"] { min-height: 220px; }
  .apexcharts-legend { font-size: 10px !important; }
  .apexcharts-xaxis-label, .apexcharts-yaxis-label { font-size: 9px !important; }
}

/* === Tab content padding mobile === */
.tab-panel { padding-bottom: env(safe-area-inset-bottom); }

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .fv2-label, .fv2-drop-spacer { flex: 0 0 56px; font-size: 9px; }
  .fv2-bar-fill, .fv2-bar-track { height: 30px; }
  .fv2-bar-value { font-size: 11px; }
  .fv2-stat, .fv2-drop-right { flex: 0 0 42px; }
  .fv2-stat-pct { font-size: 10px; }
}
@media (max-width: 640px) {
  .kpi-card .kpi-value { font-size: 1.15rem; }
  .creative-metrics { grid-template-columns: repeat(2, 1fr); }
}
