/* ============================================================================
   style.css — Dashboard Atendimento Comercial
   ============================================================================ */

:root {
  --primary: #004be3;
  --primary-light: #e8eeff;
  --secondary: #831bd7;
  --tertiary: #00647b;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Manrope', 'Inter', system-ui, sans-serif;
  font-weight: 700;
}

/* Layout */
.main-content {
  min-height: 100vh;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-left h1 {
  font-size: 1.6rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-live::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Filtro */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-bar select,
.filter-bar input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.filter-bar input[type="date"]:focus,
.filter-bar select:focus {
  border-color: var(--primary);
}

.filter-bar select {
  max-width: 200px;
  appearance: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #0040c0;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.kpi-icon.blue { background: var(--primary-light); color: var(--primary); }
.kpi-icon.purple { background: #f3e8ff; color: var(--secondary); }
.kpi-icon.teal { background: #e0f7fa; color: var(--tertiary); }
.kpi-icon.green { background: #ecfdf5; color: var(--success); }

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-value {
  font-family: 'Manrope', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Charts Section */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 20px;
  margin-bottom: 28px;
}

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

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .material-symbols-outlined {
  font-size: 1.2rem;
  color: var(--primary);
}

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

/* Table */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody tr:hover {
  background: var(--primary-light);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #e5e7eb; color: #374151; }
.rank-3 { background: #fed7aa; color: #9a3412; }
.rank-other { background: var(--bg); color: var(--text-muted); }

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

.mini-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.5s ease;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

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

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

.tab-btn .material-symbols-outlined {
  font-size: 18px;
}

.tab-pane {
  display: none;
}

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

/* Disparos: badges de tipo */
.tipo-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tipo-feedback { background: #e0e9ff; color: #004be3; }
.tipo-reengajamento { background: #f3e8ff; color: #831bd7; }
.tipo-renovacao { background: #ccfbf1; color: #00647b; }
.tipo-renovação { background: #ccfbf1; color: #00647b; }

.resp-pos { color: var(--success); font-weight: 600; }
.resp-mid { color: var(--warning); font-weight: 500; }

.mono {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 0.82rem;
}

.card-title-sub {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Distribuição de respostas (feedback) */
.feedback-dist {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dist-group h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  font-family: 'Manrope', sans-serif;
}

.dist-row {
  display: grid;
  grid-template-columns: 1fr 2fr 40px;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 0.82rem;
}

.dist-label {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-bar {
  background: var(--bg);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.dist-count {
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

/* Loading */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  flex-direction: column;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Data source badge */
.data-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 20px;
}

.data-source.mock { color: var(--warning); background: #fffbeb; }
.data-source.live { color: var(--success); background: #ecfdf5; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .material-symbols-outlined {
  font-size: 3rem;
  opacity: 0.4;
  margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 1.4rem; }
  .chart-container { height: 240px; }
}

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