/* ══════════════════════════════════════════════════════════════════
   DASHBOARD KPIs STYLES
   ══════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   TIPO DE COTIZACIÓN
   ═══════════════════════════════════════════════════════════════════ */

.tipo-row {
  display: flex;
  align-items: center;
  background: var(--card-bg, rgba(255,255,255,0.04));
  border: 1px solid rgba(139,92,246,0.15);
  border-radius: 14px;
  padding: 18px 32px;
  margin-bottom: 24px;
}
.tipo-card { flex: 1; text-align: center; }
.tipo-divider { width: 1px; height: 48px; background: rgba(139,92,246,0.2); margin: 0 32px; flex-shrink: 0; }
.tipo-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(196,164,255,0.5); margin-bottom: 6px; }
.tipo-count { font-size: 32px; font-weight: 700; color: rgba(255,255,255,0.9); font-family: 'DM Mono', monospace; }
.tipo-value { font-size: 12px; color: rgba(139,92,246,0.8); margin-top: 2px; }
.tipo-pct   { font-size: 11px; font-weight: 600; color: rgba(139,92,246,0.55); margin-top: 2px; font-family: 'DM Mono', monospace; }
:root.light-mode .tipo-pct   { color: rgba(124,58,237,0.5); }
:root.light-mode .tipo-label { color: #9e8cc5; }
:root.light-mode .tipo-count { color: #1a1033; }
:root.light-mode .tipo-value { color: #7c3aed; }

/* ═══════════════════════════════════════════════════════════════════
   STAT HINT
   ═══════════════════════════════════════════════════════════════════ */

.stat-hint {
  font-size: 10px;
  color: rgba(160, 140, 210, 0.5);
  margin-top: 4px;
  line-height: 1.3;
}
:root.light-mode .stat-hint { color: rgba(80, 60, 120, 0.45); }

/* ═══════════════════════════════════════════════════════════════════
   PERIOD SELECTOR
   ═══════════════════════════════════════════════════════════════════ */

.period-selector {
  display: flex;
  gap: 8px;
}

.period-btn {
  padding: 7px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: rgba(196, 164, 255, 0.6);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: all 0.25s ease;
}

:root.light-mode .period-btn {
  background: #ffffff;
  border: 1px solid #e0e1e8;
  color: #7a7a9e;
}

:root.light-mode .period-btn:hover {
  background: #f9f9fb;
  border-color: #7c3aed;
  color: #7c3aed;
}

:root.light-mode .period-btn.active {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: #7c3aed;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.period-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  color: rgba(196, 164, 255, 0.8);
}

.period-btn.active {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border-color: rgba(139, 92, 246, 0.6);
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════
   KAM/PM FILTER SELECT
   ═══════════════════════════════════════════════════════════════════ */

#dash-filter-kam {
  padding: 7px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: 8px;
  color: rgba(196,164,255,0.6);
  font-size: 12px;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  outline: none;
  min-width: 155px;
}
:root.light-mode #dash-filter-kam {
  background: #ffffff;
  border: 1px solid #e0e1e8;
  color: #7a7a9e;
}

/* ═══════════════════════════════════════════════════════════════════
   KPI CONVERSION RATE (color dinámico)
   ═══════════════════════════════════════════════════════════════════ */

.kpi-conversion {
  font-size: 32px !important;
  transition: color 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD CHARTS ROW (pipeline + embudo lado a lado)
   ═══════════════════════════════════════════════════════════════════ */

.dashboard-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 28px;
  align-items: start;
}

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

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

.embudo-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary, #666);
  cursor: pointer;
  user-select: none;
}
.embudo-toggle-label input[type="checkbox"] {
  accent-color: var(--accent, #6c5ce7);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════
   FUNNEL CHART (embudo de negocio)
   ═══════════════════════════════════════════════════════════════════ */

.funnel-stage {
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.funnel-stage:last-child { border-bottom: none; }

.funnel-stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.funnel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.funnel-stage-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(220,210,255,0.8);
}
.funnel-stage-metrics {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.funnel-count {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.funnel-count-label {
  font-size: 11px;
  font-weight: 400;
  color: rgba(196,164,255,0.5);
}
.funnel-value {
  font-size: 12px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
  color: rgba(167,139,250,0.85);
}
.funnel-conversion {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.funnel-arrow {
  font-size: 13px;
  color: rgba(196,164,255,0.3);
}
.funnel-conv-pct {
  font-size: 13px;
  font-weight: 700;
  color: rgba(196,164,255,0.7);
  font-family: 'DM Mono', monospace;
}
.funnel-conv-label {
  font-size: 11px;
  color: rgba(196,164,255,0.4);
}

/* Light mode */
:root.light-mode .funnel-stage { border-bottom-color: rgba(124,58,237,0.08); }
:root.light-mode .funnel-stage-name { color: #3d3060; }
:root.light-mode .funnel-count { color: #1a1033; }
:root.light-mode .funnel-count-label { color: #9e8cc5; }
:root.light-mode .funnel-value { color: #7c3aed; }
:root.light-mode .funnel-conv-pct { color: #6d28d9; }
:root.light-mode .funnel-conv-label { color: #9e8cc5; }
:root.light-mode .funnel-arrow { color: #c4b5fd; }

/* ═══════════════════════════════════════════════════════════════════
   CHART DESCRIPTION (subtítulo explicativo en cards de gráficas)
   ═══════════════════════════════════════════════════════════════════ */

.chart-desc {
  font-size: 12px;
  line-height: 1.6;
  color: rgba(196, 164, 255, 0.45);
  margin: -4px 0 18px;
}

.chart-desc strong {
  color: rgba(220, 210, 255, 0.8);
  font-weight: 700;
}

:root.light-mode .chart-desc {
  color: #9e8cc5;
}

:root.light-mode .chart-desc strong {
  color: #3d3060;
}

/* ═══════════════════════════════════════════════════════════════════
   PIE CHART (distribución por etapa)
   ═══════════════════════════════════════════════════════════════════ */

.pie-chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 4px 0;
}

.pie-svg-wrap {
  position: relative;
  width: 320px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

.pie-svg-wrap svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.pie-segment {
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.pie-center-num {
  font-size: 22px;
  font-weight: 700;
  fill: rgba(255, 255, 255, 0.92);
  font-family: 'DM Mono', monospace;
}

.pie-center-label {
  font-size: 12px;
  fill: rgba(196, 164, 255, 0.5);
  font-family: 'Sora', sans-serif;
}

:root.light-mode .pie-center-num  { fill: #1a1033; }
:root.light-mode .pie-center-label { fill: #9e8cc5; }

/* Tooltip */
.pie-tooltip {
  position: absolute;
  background: rgba(18, 13, 36, 0.97);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 20;
  min-width: 175px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}

.pie-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

:root.light-mode .pie-tooltip {
  background: #ffffff;
  border-color: rgba(124, 58, 237, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.pie-tt-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(220, 210, 255, 0.9);
  margin-bottom: 7px;
}

:root.light-mode .pie-tt-title { color: #3d3060; }

.pie-tt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: rgba(196, 164, 255, 0.6);
  margin-bottom: 5px;
}

:root.light-mode .pie-tt-row { color: #7a7a9e; }

.pie-tt-pct {
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: rgba(167, 139, 250, 0.9);
}

:root.light-mode .pie-tt-pct { color: #7c3aed; }

.pie-tt-value {
  font-size: 13px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: rgba(167, 139, 250, 0.85);
}

:root.light-mode .pie-tt-value { color: #7c3aed; }

/* Legend */
.pie-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pie-legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pie-legend-name {
  font-size: 12px;
  color: rgba(220, 210, 255, 0.7);
  flex: 1;
}

:root.light-mode .pie-legend-name { color: #3d3060; }

.pie-legend-count {
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: rgba(196, 164, 255, 0.45);
  min-width: 24px;
  text-align: right;
}

:root.light-mode .pie-legend-count { color: #9e8cc5; }

.pie-legend-pct {
  font-size: 12px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: rgba(167, 139, 250, 0.85);
  min-width: 38px;
  text-align: right;
}

:root.light-mode .pie-legend-pct { color: #7c3aed; }

/* Modo ancho completo: leyenda izquierda, SVG derecha */
#charts-row.solo .pie-chart-wrapper {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
}

#charts-row.solo .pie-svg-wrap {
  order: 2;
  width: 360px;
}

#charts-row.solo .pie-legend {
  order: 1;
  flex: 1;
  max-width: 520px;
}

/* ═══════════════════════════════════════════════════════════════════
   SELLERS TABLE ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════════ */

#sellers-table tbody tr {
  transition: all 0.18s ease;
}

#sellers-table tbody tr:hover {
  background: rgba(139, 92, 246, 0.08);
}

:root.light-mode #sellers-table tbody tr:hover {
  background: rgba(124, 58, 237, 0.05);
}

#sellers-table td:nth-child(2),
#sellers-table td:nth-child(3),
#sellers-table td:nth-child(4) {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
}

:root.light-mode #sellers-table td:nth-child(2),
:root.light-mode #sellers-table td:nth-child(3),
:root.light-mode #sellers-table td:nth-child(4) {
  color: #000000;
}

#sellers-table td:nth-child(4) {
  color: rgba(245, 158, 11, 0.85);
  font-weight: 600;
}

:root.light-mode #sellers-table td:nth-child(4) {
  color: #f59e0b;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .pie-svg-wrap {
    width: 200px;
  }
}

@media (max-width: 600px) {
  .period-selector {
    flex-wrap: wrap;
  }

  .period-btn {
    flex: 1;
    min-width: 60px;
  }

  #sellers-table {
    font-size: 12px;
  }

  #sellers-table thead th,
  #sellers-table tbody td {
    padding: 10px 12px;
  }
}
