/**
 * Meta Ads MCP UI Kit — Dark Theme Base Styles
 * Adapted from GHL MCP UI Kit with Meta Ads dark palette.
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  line-height: 1.4;
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
  overflow-y: auto;
  overflow-x: hidden;
}

#app, #root { padding: 4px; min-height: fit-content; }

a { color: #e94560; text-decoration: none; }
a:hover { text-decoration: underline; }

.font-medium { font-weight: 500; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-sm { font-size: 13px; }
.text-muted { color: #777; }
.text-secondary { color: #999; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ─── Loading & Error States ──────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 120px; color: #999;
}
.loading-spinner {
  width: 24px; height: 24px; border: 2px solid #0f3460; border-top-color: #e94560;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p { font-size: 12px; }

.error-state {
  padding: 12px; margin: 8px; background: #2d1b1b; border: 1px solid #e94560;
  border-radius: 8px; color: #e94560;
}
.error-state h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.error-state p { font-size: 12px; color: #ff6b6b; }

/* ─── Status Badges ───────────────────────────────────── */
.status-badge, .status-badge-sm {
  display: inline-flex; align-items: center; border-radius: 9999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.status-badge { padding: 4px 12px; font-size: 11px; }
.status-badge-sm { padding: 2px 6px; font-size: 9px; }

.status-active { background: rgba(39,174,96,0.2); color: #27ae60; }
.status-complete { background: rgba(39,174,96,0.2); color: #27ae60; }
.status-paused { background: rgba(243,156,18,0.2); color: #f39c12; }
.status-draft { background: rgba(149,165,166,0.2); color: #95a5a6; }
.status-error { background: rgba(231,76,60,0.2); color: #e74c3c; }
.status-sent { background: rgba(52,152,219,0.2); color: #3498db; }
.status-paid { background: rgba(39,174,96,0.2); color: #27ae60; }
.status-pending { background: rgba(243,156,18,0.2); color: #f39c12; }
.status-open { background: rgba(52,152,219,0.2); color: #3498db; }
.status-won { background: rgba(39,174,96,0.2); color: #27ae60; }
.status-lost { background: rgba(231,76,60,0.2); color: #e74c3c; }

/* ─── Page Header ─────────────────────────────────────── */
.page-header {
  background: #16213e; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.page-header-gradient {
  background: linear-gradient(135deg, #e94560, #0f3460);
  color: white; padding: 8px 12px; position: sticky; top: 0; z-index: 50;
  border-radius: 8px; margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(233,69,96,0.3);
}
.page-header-top { display: flex; align-items: center; justify-content: space-between; }
.page-header-title { font-size: 14px; font-weight: 700; color: #fff; }
.page-header-title-light { font-size: 13px; font-weight: 600; }
.page-header-subtitle { font-size: 11px; color: #999; margin-top: 2px; }
.page-header-subtitle-light { font-size: 10px; opacity: 0.8; margin-top: 1px; }
.badge-light { padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600; background: rgba(255,255,255,0.2); }
.page-header-stats { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.page-header-stats-light { display: flex; gap: 10px; margin-top: 4px; }
.stat-item { font-size: 11px; color: #999; }
.stat-value { font-weight: 500; color: #e0e0e0; }
.stat-item-light { font-size: 10px; display: flex; align-items: center; gap: 4px; }
.stat-value-light { font-weight: 600; }
.stat-label-light { opacity: 0.7; }

/* ─── Card ────────────────────────────────────────────── */
.card {
  background: #16213e; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  overflow: hidden; margin-bottom: 8px;
}
.card.no-border { box-shadow: none; }
.card-header { padding: 8px 12px; border-bottom: 1px solid #0f3460; }
.card-title { font-size: 13px; font-weight: 600; color: #fff; }
.card-subtitle { font-size: 11px; color: #999; margin-top: 1px; }
.card-body.p-0 { padding: 0; }
.card-body.p-sm { padding: 8px; }
.card-body.p-md { padding: 10px; }
.card-body.p-lg { padding: 12px; }

/* ─── Stats Grid ──────────────────────────────────────── */
.stats-grid { display: grid; gap: 8px; margin-bottom: 8px; }
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-6 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
  .stats-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .stats-grid-6 { grid-template-columns: repeat(6, 1fr); }
}

/* ─── Split Layout ────────────────────────────────────── */
.split-layout { display: grid; }
.split-50-50 { grid-template-columns: 1fr; }
.split-33-67 { grid-template-columns: 1fr; }
.split-67-33 { grid-template-columns: 1fr; }
.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 14px; }
@media (min-width: 640px) {
  .split-50-50 { grid-template-columns: 1fr 1fr; }
  .split-33-67 { grid-template-columns: 1fr 2fr; }
  .split-67-33 { grid-template-columns: 2fr 1fr; }
}

/* ─── Section ─────────────────────────────────────────── */
.section { margin-bottom: 8px; }
.section-header { margin-bottom: 6px; }
.section-title { font-size: 13px; font-weight: 600; color: #fff; }
.section-desc { font-size: 11px; color: #999; margin-top: 1px; }

/* ─── Metric Card ─────────────────────────────────────── */
.metric-card {
  background: #16213e; border-radius: 8px; padding: 10px;
  text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.metric-value { font-size: 18px; font-weight: 700; color: #e94560; }
.metric-green { color: #27ae60; }
.metric-blue { color: #3498db; }
.metric-purple { color: #9b59b6; }
.metric-yellow { color: #f39c12; }
.metric-red { color: #e74c3c; }
.metric-label { font-size: 10px; color: #999; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-trend { font-size: 11px; font-weight: 600; margin-top: 4px; }
.trend-up { color: #27ae60; }
.trend-down { color: #e74c3c; }
.trend-flat { color: #999; }

/* ─── Data Table ──────────────────────────────────────── */
.data-table-wrap {
  background: #16213e; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  overflow: hidden;
}
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th {
  text-align: left; padding: 6px 8px; background: #0f3460; color: #999;
  font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid #0f3460; white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #1a2a4e; }
.data-table td { padding: 5px 8px; border-bottom: 1px solid #0f3460; vertical-align: middle; color: #ddd; }
.data-table tr:hover { background: #1a2a4e; }

.avatar-cell { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 200px; }
.tag {
  display: inline-block; padding: 2px 8px; background: rgba(233,69,96,0.15); color: #e94560;
  border-radius: 12px; font-size: 11px; font-weight: 500;
}
.tag-more { background: rgba(149,165,166,0.2); color: #999; }
.link { color: #e94560; text-decoration: none; }
.link:hover { text-decoration: underline; }

.table-pagination {
  padding: 12px 20px; border-top: 1px solid #0f3460; display: flex;
  justify-content: space-between; align-items: center;
}
.pagination-info { font-size: 13px; color: #999; }
.pagination-buttons { display: flex; gap: 8px; }

.empty-state { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { color: #999; font-size: 15px; }

/* ─── Search Bar ──────────────────────────────────────── */
.search-bar { padding: 12px 20px; background: #0f3460; border-bottom: 1px solid #16213e; }
.search-input {
  width: 100%; padding: 8px 12px; border: 1px solid #1a2a4e; border-radius: 6px;
  font-size: 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  background: #16213e; color: #e0e0e0;
}
.search-input:focus { border-color: #e94560; box-shadow: 0 0 0 3px rgba(233,69,96,0.15); }

/* ─── Filter Chips ────────────────────────────────────── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.chip {
  padding: 4px 12px; border-radius: 9999px; font-size: 12px; font-weight: 500;
  background: #0f3460; color: #999; border: 1px solid #1a2a4e; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip:hover { background: #1a2a4e; color: #e0e0e0; }
.chip-active { background: #e94560; color: white; border-color: #e94560; }
.chip-active:hover { background: #c0392b; }

/* ─── Tab Group ───────────────────────────────────────── */
.tab-group { display: flex; border-bottom: 1px solid #0f3460; margin-bottom: 16px; }
.tab {
  padding: 8px 16px; font-size: 14px; font-weight: 500; border: none; background: none;
  border-bottom: 2px solid transparent; color: #999; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #e0e0e0; border-bottom-color: #1a2a4e; }
.tab-active { color: #e94560; border-bottom-color: #e94560; }
.tab-count {
  margin-left: 6px; padding: 1px 6px; background: #0f3460; color: #999;
  border-radius: 9999px; font-size: 12px;
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; border-radius: 8px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s; border: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #e94560; color: white; box-shadow: 0 2px 4px rgba(233,69,96,0.3); }
.btn-primary:hover:not(:disabled) { background: #c0392b; }
.btn-secondary { background: #0f3460; color: #e0e0e0; border: 1px solid #1a2a4e; }
.btn-secondary:hover:not(:disabled) { background: #1a2a4e; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-ghost { background: none; color: #999; }
.btn-ghost:hover:not(:disabled) { background: #0f3460; color: #e0e0e0; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-md { padding: 8px 16px; font-size: 14px; }
.btn-lg { padding: 10px 24px; font-size: 16px; }

/* ─── Progress Bar ────────────────────────────────────── */
.progress-track { position: relative; height: 8px; background: #0f3460; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.5s; }
.bar-green { background: linear-gradient(to right, #27ae60, #2ecc71); }
.bar-blue { background: linear-gradient(to right, #3498db, #2980b9); }
.bar-purple { background: linear-gradient(to right, #9b59b6, #8e44ad); }
.bar-yellow { background: linear-gradient(to right, #f39c12, #e67e22); }
.bar-red { background: linear-gradient(to right, #e94560, #ff6b9d); }

/* ─── Chart Components ────────────────────────────────── */
.chart-container {
  background: #16213e; border-radius: 12px; padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); margin-bottom: 16px;
}
.chart-title { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 12px; }
.chart-scroll { overflow-x: auto; }
.chart-empty { text-align: center; color: #999; padding: 32px; font-size: 14px; }

/* Bar Chart */
.bar-chart-h { display: flex; flex-direction: column; gap: 10px; }
.bar-h-row { display: flex; align-items: center; gap: 10px; }
.bar-h-label { width: 90px; font-size: 13px; color: #e0e0e0; font-weight: 500; text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-h-track { flex: 1; height: 24px; background: #0f3460; border-radius: 6px; overflow: hidden; }
.bar-h-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; min-width: 2px; }
.bar-h-value { width: 60px; font-size: 13px; font-weight: 600; color: #fff; font-family: 'SF Mono', 'Fira Code', monospace; }

.bar-chart-svg { width: 100%; height: auto; max-height: 200px; }
.bar-v-rect { transition: opacity 0.2s; }
.bar-v-rect:hover { opacity: 0.8; }
.bar-v-val { font-size: 11px; fill: #fff; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.bar-v-label { font-size: 10px; fill: #999; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* Line Chart */
.line-chart-svg { width: 100%; height: auto; max-height: 200px; }
.chart-axis-text { font-size: 10px; fill: #777; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.chart-axis-label { font-size: 10px; fill: #999; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* Pie Chart */
.pie-chart-layout { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.pie-chart-svg { width: 160px; height: 160px; flex-shrink: 0; }
.pie-center-text { font-size: 18px; font-weight: 700; fill: #fff; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { color: #e0e0e0; flex: 1; }
.pie-legend-value { color: #999; font-weight: 500; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

/* Funnel Chart */
.funnel-chart { display: flex; flex-direction: column; gap: 8px; }
.funnel-stage { display: flex; align-items: center; gap: 12px; }
.funnel-label-col { width: 100px; flex-shrink: 0; text-align: right; }
.funnel-label { display: block; font-size: 13px; font-weight: 500; color: #e0e0e0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-value { display: block; font-size: 11px; color: #999; font-family: 'SF Mono', 'Fira Code', monospace; }
.funnel-bar-col { flex: 1; }
.funnel-bar { height: 28px; border-radius: 6px; transition: width 0.4s ease; min-width: 4px; }
.funnel-dropoff { width: 50px; font-size: 11px; color: #e74c3c; font-weight: 600; text-align: left; flex-shrink: 0; }

/* ─── Clickable Rows ──────────────────────────────────── */
.clickable-row { cursor: pointer; transition: background 0.1s; }
.clickable-row:hover { background: #1a2a4e !important; }
