/* ================================================================
   DASHBOARD GRID — Primitivo de Cuadrícula y Widgets para Webkor
   Estructura estándar de 12 columnas (3 arriba / 2 abajo)
   Integrado con design-tokens.css y frontend-uidesign
   ================================================================ */

/* ── CONTENEDOR PRINCIPAL DEL GRID ── */
.wk-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-4, 16px);
  width: 100%;
  box-sizing: border-box;
}

/* ── SLOTS DE LA GRILLA (12 COLUMNAS) ── */
.wk-slot-top-left {
  grid-column: span 4;
}

.wk-slot-top-center {
  grid-column: span 5;
}

.wk-slot-top-right {
  grid-column: span 3;
}

.wk-slot-bottom-left {
  grid-column: span 4;
}

.wk-slot-bottom-right {
  grid-column: span 8;
}

.wk-slot-top-left,
.wk-slot-top-center,
.wk-slot-top-right,
.wk-slot-bottom-left,
.wk-slot-bottom-right {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

/* ── ADAPTACIÓN RESPONSIVA (TABLETS <= 1024px) ── */
@media (max-width: 1024px) {
  .wk-slot-top-left {
    grid-column: span 6;
  }
  .wk-slot-top-center {
    grid-column: span 6;
  }
  .wk-slot-top-right {
    grid-column: span 12;
  }
  .wk-slot-bottom-left {
    grid-column: span 5;
  }
  .wk-slot-bottom-right {
    grid-column: span 7;
  }
}

/* ── ADAPTACIÓN RESPONSIVA (MÓVIL <= 768px) ── */
@media (max-width: 768px) {
  .wk-dashboard-grid {
    gap: var(--sp-3, 12px);
  }
  .wk-slot-top-left,
  .wk-slot-top-center,
  .wk-slot-top-right,
  .wk-slot-bottom-left,
  .wk-slot-bottom-right {
    grid-column: span 12 !important;
  }
}

/* ── TARJETA BASE DEL DASHBOARD (.wk-dash-card) ── */
.wk-dash-card {
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--surface-border, #e2e8f0);
  border-radius: var(--radius-xl, 10px);
  padding: var(--sp-4, 16px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
  position: relative;
  box-sizing: border-box;
  transition: box-shadow var(--transition-fast, 150ms ease), border-color var(--transition-fast, 150ms ease);
  height: 100%;
  flex: 1 1 auto;
  min-height: 220px;
}

.wk-dash-card:hover {
  box-shadow: var(--shadow-md, 0 4px 12px rgba(15, 23, 42, 0.06));
}

/* ── ENCABEZADO DE TARJETA ── */
.wk-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2, 8px);
  padding-bottom: var(--sp-3, 10px);
  margin-bottom: var(--sp-3, 10px);
  border-bottom: 1px solid var(--surface-border, #f1f5f9);
}

.wk-card-title-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2, 8px);
  min-width: 0;
}

.wk-card-icon {
  font-size: 14px;
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
}

.wk-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-card-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

.wk-card-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-md, 4px);
  background: var(--blue-50, #eff6ff);
  color: var(--primary-600, #1d4ed8);
  border: 1px solid var(--blue-200, #bfdbfe);
  white-space: nowrap;
}

.wk-card-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1, 4px);
  flex-shrink: 0;
}

/* ── CUERPO DE TARJETA ── */
.wk-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-height: 0;
}

/* ── PIE DE TARJETA ── */
.wk-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--sp-2, 8px);
  margin-top: var(--sp-2, 8px);
  border-top: 1px solid var(--surface-border, #f1f5f9);
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
}

.wk-card-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wk-card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.wk-card-note {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
}

/* ── BOTONES E ICONOS DE TOOLBAR ── */
.wk-dash-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-bg, #f8fafc);
  padding: 2px;
  border-radius: var(--radius-md, 4px);
  border: 1px solid var(--surface-border, #e2e8f0);
}

.wk-dash-tool-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast, 150ms ease);
}

.wk-dash-tool-btn:hover {
  background: var(--surface-card, #ffffff);
  color: var(--text-primary, #0f172a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wk-dash-tool-btn.is-active {
  background: var(--surface-card, #ffffff);
  color: var(--primary-600, #1c3a5a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.wk-btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  padding: 4px;
  border-radius: var(--radius-md, 4px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wk-btn-icon:hover {
  color: var(--text-primary, #0f172a);
  background: var(--surface-hover, #f1f5f9);
}

.wk-link-action {
  color: var(--primary-500, #274c72);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wk-link-action:hover {
  text-decoration: underline;
}

/* ── HERO KPI CARD (.wk-hero-card) ── */
.wk-hero-card {
  background: linear-gradient(135deg, var(--primary-600, #1c3a5a) 0%, var(--primary-800, #0f2036) 100%);
  color: #ffffff;
  border: none;
  min-height: 220px;
  height: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.wk-hero-card::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -20%;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.14) 0%, transparent 70%);
  pointer-events: none;
}

.wk-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  z-index: 2;
}

.wk-hero-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: var(--radius-md, 4px);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.wk-hero-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  padding: var(--sp-2, 8px) 0;
  z-index: 2;
}

.wk-hero-value {
  font-size: clamp(2.5rem, 3.5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wk-hero-subtitle {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  margin-top: 6px;
  text-align: center;
  padding: 0 8px;
}

.wk-hero-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: var(--sp-2, 8px);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
  z-index: 2;
}

.wk-hero-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.wk-hero-trend.is-up {
  color: #6ee7b7;
}

.wk-hero-trend.is-down {
  color: #fca5a5;
}

/* ── HELPER: BARRA HORIZONTAL APILADA (SLOT 1) ── */
.wk-stacked-bar-group {
  margin-bottom: clamp(10px, 1.2vw, 16px);
}

.wk-stacked-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-bottom: 5px;
}

.wk-stacked-bar-val {
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.wk-stacked-bar-track {
  width: 100%;
  height: clamp(28px, 2.2vw, 34px);
  background: var(--surface-bg, #f1f5f9);
  border-radius: var(--radius-lg, 6px);
  overflow: hidden;
  display: flex;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wk-stacked-bar-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  transition: width var(--transition-base, 300ms ease);
}

.wk-scale-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  padding: 0 2px;
  margin-top: 4px;
}

/* ── HELPER: GRÁFICO CIRCULAR / PIE & DONUT (SLOTS 2 Y 4) ── */
.wk-chart-circular-wrap {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: var(--sp-4, 16px);
  padding: var(--sp-2, 8px) 0;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}

.wk-circular-svg-box {
  position: relative;
  width: clamp(130px, 10vw, 170px);
  height: clamp(130px, 10vw, 170px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wk-circular-svg-box svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.wk-donut-center-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.wk-donut-center-val {
  font-size: clamp(1.2rem, 1.5vw, 1.55rem);
  font-weight: 800;
  color: var(--text-primary, #0f172a);
  line-height: 1.1;
}

.wk-donut-center-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
  letter-spacing: 0.5px;
}

.wk-chart-legend {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-2, 8px);
  font-size: 0.78rem;
  min-width: 0;
  flex: 1 1 auto;
}

.wk-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary, #64748b);
}

.wk-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.wk-legend-val {
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

/* ── HELPER: GRÁFICO DE COLUMNAS APILADAS (SLOT 5) ── */
.wk-columns-chart-container {
  width: 100%;
  min-height: clamp(165px, 18vh, 230px);
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2, 8px);
  padding: var(--sp-4, 16px) var(--sp-2, 8px) var(--sp-2, 8px);
  position: relative;
  border-bottom: 1px solid var(--surface-border, #f1f5f9);
  box-sizing: border-box;
}

.wk-chart-guideline {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px dashed var(--surface-border, #e2e8f0);
  pointer-events: none;
}

.wk-chart-guideline.guide-top { top: 25px; }
.wk-chart-guideline.guide-mid { top: 65px; }
.wk-chart-guideline.guide-low { top: 105px; }

.wk-col-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

.wk-col-bar {
  width: 100%;
  max-width: clamp(34px, 3.5vw, 52px);
  display: flex;
  flex-direction: column-reverse;
  border-radius: var(--radius-md, 4px) var(--radius-md, 4px) 0 0;
  overflow: hidden;
  transition: transform var(--transition-fast, 150ms ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.wk-col-track:hover .wk-col-bar {
  transform: scaleY(1.04);
}

.wk-col-seg {
  width: 100%;
  transition: height var(--transition-base, 300ms ease);
}

.wk-col-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
}

/* ── MODO OSCURO (DATA-THEME / DARK) ── */
[data-theme="dark"] .wk-dash-card {
  background: var(--surface-card, #1e293b);
  border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .wk-card-header,
[data-theme="dark"] .wk-card-footer,
[data-theme="dark"] .wk-columns-chart-container {
  border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .wk-stacked-bar-track {
  background: var(--gray-800, #0f172a);
}

[data-theme="dark"] .wk-chart-guideline {
  border-color: var(--gray-800, #334155);
}

[data-theme="dark"] .wk-dash-toolbar {
  background: var(--gray-800, #0f172a);
  border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .wk-dash-tool-btn:hover {
  background: var(--gray-700, #1e293b);
}

[data-theme="dark"] .wk-dash-tool-btn.is-active {
  background: var(--gray-700, #1e293b);
  color: #60a5fa;
}

[data-theme="dark"] .wk-donut-center-val {
  color: #f8fafc;
}
