/* ══════════════════════════════════════════════════════════
   WK-CHARTS — CSS-Only Chart Components for Work Hub
   ══════════════════════════════════════════════════════════
   Donut rings, gauge arcs, horizontal bar charts,
   stacked meter bars, mini sparkline bars.
   All pure CSS — no JS library needed.
   ══════════════════════════════════════════════════════════ */

/* ── Donut Ring (SVG-based via CSS) ──────────────────── */
.wk-ring {
  position: relative; width: 80px; height: 80px; flex-shrink: 0;
}
.wk-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.wk-ring-bg {
  fill: none; stroke: var(--wt-border, #e2e8f0); stroke-width: 6;
}
.wk-ring-fill {
  fill: none; stroke-width: 6; stroke-linecap: round;
  transition: stroke-dashoffset .8s cubic-bezier(.22,1,.36,1);
}
.wk-ring-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: var(--wt-text, #1e293b); line-height: 1.1;
}
.wk-ring-sublabel {
  font-size: 0.55rem; font-weight: 600; color: var(--wt-text-muted, #94a3b8);
  text-transform: uppercase; letter-spacing: .04em; margin-top: 1px;
}
.wk-ring--sm { width: 56px; height: 56px; }
.wk-ring--sm .wk-ring-label { font-size: 0.85rem; }
.wk-ring--sm .wk-ring-sublabel { font-size: 0.5rem; }
.wk-ring--lg { width: 100px; height: 100px; }
.wk-ring--lg .wk-ring-label { font-size: 1.4rem; }

/* ── Horizontal Stacked Bar ──────────────────────────── */
.wk-hbar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  background: var(--wt-border, #e2e8f0);
}
.wk-hbar-seg {
  height: 100%; transition: width .6s cubic-bezier(.22,1,.36,1);
  min-width: 2px;
}
.wk-hbar--thin { height: 6px; border-radius: 3px; }
.wk-hbar--thick { height: 14px; border-radius: 7px; }

/* ── Vertical Bar Chart ──────────────────────────────── */
.wk-vbars {
  display: flex; align-items: flex-end; gap: 4px;
  height: 80px; padding: 0 4px;
}
.wk-vbar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end; gap: 3px;
}
.wk-vbar {
  width: 100%; max-width: 28px; min-height: 3px; border-radius: 4px 4px 0 0;
  transition: height .5s cubic-bezier(.22,1,.36,1);
}
.wk-vbar-lbl {
  font-size: 0.55rem; color: var(--wt-text-muted, #94a3b8); font-weight: 600;
  letter-spacing: .02em; white-space: nowrap;
}

/* ── KPI Card with Ring ──────────────────────────────── */
.wk-kpi-ring {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--wt-card-bg, #fff); border: 1.5px solid var(--wt-border, #e2e8f0);
  border-radius: 14px; flex: 1 1 200px; min-width: 180px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.wk-kpi-ring:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); transform: translateY(-1px); }
.wk-kpi-ring-info { flex: 1; min-width: 0; }
.wk-kpi-ring-value {
  font-size: 1.1rem; font-weight: 800; color: var(--wt-text, #1e293b); line-height: 1.2;
}
.wk-kpi-ring-label {
  font-size: 0.68rem; font-weight: 600; color: var(--wt-text-muted, #64748b);
  text-transform: uppercase; letter-spacing: .04em; margin-top: 2px;
}
.wk-kpi-ring-sub {
  font-size: 0.64rem; color: var(--wt-text-muted, #94a3b8); margin-top: 1px;
}

/* ── Status Distribution Bar ─────────────────────────── */
.wk-dist-bar {
  display: flex; gap: 0; height: 8px; border-radius: 4px; overflow: hidden;
  background: var(--wt-border-light, #f1f5f9); margin: 6px 0;
}
.wk-dist-seg { height: 100%; transition: width .6s ease; }
.wk-dist-legend {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px;
}
.wk-dist-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.68rem; color: var(--wt-text-muted, #64748b);
}
.wk-dist-legend-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* ── Percentage Pill ─────────────────────────────────── */
.wk-pct-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 20px; font-size: 0.72rem; font-weight: 700;
}
.wk-pct-pill--green  { background: #dcfce7; color: #166534; }
.wk-pct-pill--yellow { background: #fef3c7; color: #92400e; }
.wk-pct-pill--red    { background: #fee2e2; color: #991b1b; }
.wk-pct-pill--gray   { background: #f1f5f9; color: #64748b; }

/* ── Mini Trend Sparkline ────────────────────────────── */
.wk-spark {
  display: flex; align-items: flex-end; gap: 2px; height: 24px;
}
.wk-spark-bar {
  flex: 1; min-width: 3px; max-width: 6px; border-radius: 2px 2px 0 0;
  background: var(--wt-theme-primary, #6366f1); opacity: .7;
  transition: height .4s ease;
}
.wk-spark-bar:last-child { opacity: 1; }

/* ── Detail Popup / Modal Tabs ───────────────────────── */
.wk-detail-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s cubic-bezier(.22,1,.36,1);
}
.wk-detail-modal.is-open { opacity: 1; pointer-events: all; }

.wk-detail-panel {
  background: var(--wt-card-bg, #fff); border-radius: 20px;
  width: 92vw; max-width: 720px; max-height: 88vh; overflow: hidden;
  box-shadow: 0 32px 100px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.05);
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(.96); opacity: 0;
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .25s ease;
}
.wk-detail-modal.is-open .wk-detail-panel {
  transform: translateY(0) scale(1); opacity: 1;
}

.wk-detail-header {
  display: flex; align-items: center; gap: 14px;
  padding: 22px 28px 16px; border-bottom: 1px solid var(--wt-border, #e2e8f0);
}
.wk-detail-header-icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  color: #fff; font-size: 1.2rem;
}
.wk-detail-header-info { flex: 1; min-width: 0; }
.wk-detail-title {
  font-size: 1.15rem; font-weight: 700; color: var(--wt-text, #1e293b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wk-detail-subtitle {
  font-size: 0.75rem; color: var(--wt-text-muted, #64748b); margin-top: 2px;
}
.wk-detail-close {
  border: none; background: none; cursor: pointer; padding: 8px;
  border-radius: 8px; color: var(--wt-text-muted, #94a3b8);
  font-size: 1.3rem; line-height: 1;
  transition: all .15s ease;
}
.wk-detail-close:hover { background: #fee2e2; color: #ef4444; }

/* Tabs inside detail popup */
.wk-detail-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--wt-border, #e2e8f0);
  padding: 0 28px; overflow-x: auto;
}
.wk-detail-tab {
  padding: 12px 18px; font-size: 0.8rem; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--wt-text-muted, #64748b);
  border-bottom: 2.5px solid transparent; white-space: nowrap;
  transition: all .2s ease;
}
.wk-detail-tab:hover { color: var(--wt-text, #1e293b); background: var(--wt-bg, #f8fafc); }
.wk-detail-tab.is-active {
  color: var(--wt-theme-primary, #6366f1); font-weight: 700;
  border-bottom-color: var(--wt-theme-primary, #6366f1);
}

.wk-detail-body {
  flex: 1; overflow-y: auto; padding: 24px 28px;
}
.wk-detail-pane { display: none; animation: wkDetailFadeIn .2s ease both; }
.wk-detail-pane.is-active { display: block; }
@keyframes wkDetailFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Chart row inside detail */
.wk-chart-row {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.wk-chart-card {
  flex: 1 1 200px; min-width: 160px; padding: 16px;
  background: var(--wt-bg, #f8fafc); border: 1px solid var(--wt-border-light, #f1f5f9);
  border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.wk-chart-title {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--wt-text-muted, #64748b); align-self: stretch;
}

/* Inline stat row */
.wk-stat-row {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.wk-stat {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 14px;
  background: var(--wt-card-bg, #fff); border: 1px solid var(--wt-border, #e2e8f0);
  border-radius: 10px; flex: 1 1 100px; min-width: 80px; text-align: center;
}
.wk-stat-val { font-size: 1.2rem; font-weight: 800; color: var(--wt-text, #1e293b); }
.wk-stat-lbl {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--wt-text-muted, #94a3b8);
}
