/**
 * Legacy Compatibility CSS
 * Estilos das views antigas migradas
 * Para manter compatibilidade com Performance, CI, etc
 */

/* ===== GLASS EFFECT ===== */
.glass {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

[data-theme="light"] .glass {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

/* ===== TOPBAR (das views antigas) ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.tb-badge {
  padding: 4px 10px;
  background: var(--emerald);
  color: #000;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tb-tabs {
  display: flex;
  gap: var(--space-2);
}

.tb-tab {
  position: relative;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.tb-tab.active {
  background: var(--emerald);
  color: #000;
  font-weight: var(--font-weight-semibold);
}

.tb-back {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
}

.tb-back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ===== CONTROLS BAR ===== */
.ctrl-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
}

.period-btns {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
}

.p-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.p-btn.active {
  background: var(--emerald);
  color: #000;
}

.f-sel, .f-search {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.f-search {
  min-width: 200px;
}

.ctrl-right {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.updated {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-fast);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

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

.btn-ai {
  background: var(--violet);
  color: #fff;
}

.btn-ai:hover {
  background: var(--violet-hover);
}

/* ===== KPI CARDS ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi {
  padding: var(--space-4);
  text-align: center;
}

.kpi-val {
  font-size: 28px;
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kpi-lbl {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-weight-semibold);
  margin-bottom: 8px;
}

.kpi-delta {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.kpi-delta.positive { color: var(--emerald); }
.kpi-delta.negative { color: var(--rose); }
.kpi-delta.neutral { color: var(--text-tertiary); }

/* ===== AI CARD ===== */
.ai-card {
  margin-bottom: var(--space-6);
}

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

.ai-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.ai-toggle {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  cursor: pointer;
}

.ai-toggle:hover {
  color: var(--text-primary);
}

.ai-body {
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-tertiary);
}

/* ===== CHART ===== */
.chart-wrap {
  margin-bottom: var(--space-6);
  padding: var(--space-6);
}

.chart-container {
  position: relative;
  height: 400px;
}

/* ===== TABLE ===== */
.tbl-wrap {
  overflow-x: auto;
}

.dtbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.dtbl thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dtbl th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
}

.dtbl td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.dtbl tbody tr {
  transition: background var(--transition-fast);
}

.dtbl tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .dtbl tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

.loading-center {
  text-align: center;
  padding: 40px !important;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== TAB CONTENT ===== */
.tab-content {
  display: none;
}

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

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-amber { color: var(--amber); }

.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

/* ===== ADDITIONAL LEGACY STYLES ===== */

/* Chips & Badges */
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chip-btn.active {
  background: var(--emerald);
  color: #000;
  border-color: var(--emerald);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
}

.badge-green { background: rgba(52, 211, 153, 0.15); color: var(--emerald); }
.badge-gray { background: rgba(255, 255, 255, 0.08); color: var(--text-tertiary); }

/* Goal Pills */
.goal-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--sky);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
}

/* Breakdowns */
.brk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.brk-card {
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.brk-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.brk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.brk-row:last-child {
  border-bottom: none;
}

.brk-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.brk-val {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.brk-pct {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-left: 8px;
}

.brk-bars {
  margin-top: 8px;
}

/* Input Groups */
.input-group {
  margin-bottom: var(--space-4);
}

.input-group label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.input-group textarea {
  min-height: 100px;
  resize: vertical;
}

/* Save Button */
.btn-save {
  padding: 8px 16px;
  background: var(--emerald);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-save:hover {
  background: var(--emerald-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status Indicators */
.key-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.key-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.key-status.status-ok::before { background: var(--emerald); }
.key-status.status-missing::before { background: var(--rose); }
.key-status.status-pending::before { background: var(--amber); }

.status-missing {
  color: var(--rose);
}

/* Camp Table */
.camp-table {
  width: 100%;
  border-collapse: collapse;
}

.camp-table th,
.camp-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.camp-table th {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.camp-table td {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* Columns */
.result-col,
.cost-col {
  text-align: right;
  font-weight: var(--font-weight-semibold);
}

.result-col { color: var(--emerald); }
.cost-col { color: var(--text-primary); }

/* Tooltip */
.tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.tb-tab:hover .tooltip {
  opacity: 1;
}

/* Right align */
.right {
  text-align: right;
}

/* Expand rows */
.ads-expand-row,
.adset-expand-row {
  background: var(--bg-tertiary);
}

.ads-expand-row.show,
.adset-expand-row.show {
  display: table-row;
}

/* Performance indicators */
.m-good { color: var(--emerald) !important; }
.m-ok { color: var(--amber) !important; }
.m-bad { color: var(--rose) !important; }

/* AI Styles */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.ai-box-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.ai-workflows-box,
.ai-keys-box {
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.ai-panel {
  padding: var(--space-4);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.ai-panel-header {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.alert-box {
  padding: var(--space-3) var(--space-4);
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--amber);
}

/* Asset rows */
.asset-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.asset-row:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.asset-radio {
  flex-shrink: 0;
}

.asset-info {
  flex: 1;
}

.asset-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.asset-meta {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* Gestor badges */
.b-local,
.b-jadson {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
}

.b-local { background: rgba(52, 211, 153, 0.15); color: var(--emerald); }
.b-jadson { background: rgba(160, 139, 250, 0.15); color: var(--violet); }

/* Expandable */
.expanded {
  background: var(--bg-tertiary) !important;
}

.show {
  display: block !important;
}

/* ===== CHAT PANEL ===== */
.chat-overlay {
  position: fixed;
  right: -450px;
  top: 52px;
  bottom: 0;
  width: 420px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  transition: right var(--transition-base);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.chat-overlay.show {
  right: 0;
  display: flex !important;
}

.chat-head {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-head h3 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.chat-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  transition: color var(--transition-fast);
}

.chat-close:hover {
  color: var(--text-primary);
}

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.msg {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  max-width: 85%;
}

.msg.ai {
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: var(--text-primary);
  align-self: flex-start;
}

.msg.user {
  background: var(--emerald);
  color: #000;
  align-self: flex-end;
  font-weight: var(--font-weight-medium);
}

.chat-typing {
  display: none;
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  font-style: italic;
}

.chat-typing.show {
  display: block;
}

.chat-bottom {
  border-top: 1px solid var(--border-default);
  padding: var(--space-4);
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.chat-input:focus {
  outline: none;
  border-color: var(--emerald);
}

.chat-send {
  padding: 10px 16px;
  background: var(--emerald);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-send:hover {
  background: var(--emerald-hover, #10b981);
  transform: translateY(-1px);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition-base);
  pointer-events: none;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.success {
  background: rgba(52, 211, 153, 0.1);
  border-color: var(--emerald);
  color: var(--emerald);
}

.toast.error {
  background: rgba(251, 113, 133, 0.1);
  border-color: var(--rose);
  color: var(--rose);
}

.toast.info {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--sky);
  color: var(--sky);
}

/* ===== HIDDEN UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== SELECT STYLING ===== */
.select {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select:hover {
  border-color: var(--border-strong);
}

.select:focus {
  outline: none;
  border-color: var(--emerald);
}

