/* ═══════════════════════════════════════════════════════════════
   Analysis Panel — Skeleton CSS
   Minimal structure only. No design system, no polish.
   Just enough to validate the VM → UI rendering pipeline.
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   Panel Shell
   ───────────────────────────────────────────────────────────── */

.ap {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  background: rgba(255, 255, 255, 0.97);
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: #1a1a1a;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.ap--dock-right {
  right: 0;
}

.ap--dock-left {
  left: 0;
  border-left: none;
  border-right: 1px solid #e0e0e0;
}

.ap--hidden {
  display: none;
}

.ap--collapsed {
  height: auto;
  bottom: auto;
  top: 16px;
  right: 16px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ─────────────────────────────────────────────────────────────
   Header
   ───────────────────────────────────────────────────────────── */

.ap__header {
  padding: 12px 16px 0;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.ap__title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ap__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.ap__header-actions {
  display: flex;
  gap: 4px;
}

.ap__btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #555;
}

.ap__btn:hover {
  background: #f0f0f0;
}

.ap__btn--icon {
  font-size: 14px;
  width: auto;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────────
   Tab Bar
   ───────────────────────────────────────────────────────────── */

.ap__tab-bar {
  display: flex;
  gap: 2px;
  padding-bottom: 0;
  overflow-x: auto;
}

.ap__tab {
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 12px 8px;
  font-size: 12px;
  color: #666;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
}

.ap__tab:hover {
  color: #333;
}

.ap__tab--active {
  color: #1a1a1a;
  border-bottom-color: #2563eb;
  font-weight: 500;
}

.ap__tab-label {
  font-size: 12px;
}

.ap__tab-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 500;
}

.ap__tab-badge--info {
  background: #e8f0fe;
  color: #1a73e8;
}

.ap__tab-badge--warning {
  background: #fef3cd;
  color: #856404;
}

.ap__tab-badge--error {
  background: #f8d7da;
  color: #721c24;
}

/* ─────────────────────────────────────────────────────────────
   Body (scrollable content area)
   ───────────────────────────────────────────────────────────── */

.ap__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
}

/* ─────────────────────────────────────────────────────────────
   Tab Meta
   ───────────────────────────────────────────────────────────── */

.ap__tab-meta {
  margin-bottom: 12px;
}

.ap__tab-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.ap__tab-subtitle {
  font-size: 11px;
  color: #888;
  font-family: "SF Mono", "Menlo", monospace;
}

/* ─────────────────────────────────────────────────────────────
   Pin Controls — Mode toggle + Save / Delete
   ───────────────────────────────────────────────────────────── */

.ap__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 0;
}

.ap__controls-modes {
  display: flex;
  gap: 2px;
  background: #f0f0f0;
  border-radius: 6px;
  padding: 2px;
}

.ap__controls-actions {
  display: flex;
  gap: 4px;
}

.ap__controls-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #666;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.ap__controls-btn:hover {
  background: #e4e4e4;
  color: #333;
}

.ap__controls-btn--mode {
  font-size: 11px;
}

.ap__controls-btn--active {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

.ap__controls-btn--active:hover {
  background: #fff;
}

.ap__controls-btn--save {
  color: #2563eb;
}

.ap__controls-btn--save:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.ap__controls-btn--delete {
  color: #dc2626;
}

.ap__controls-btn--delete:hover {
  background: #fef2f2;
  color: #b91c1c;
}

/* ─────────────────────────────────────────────────────────────
   Status States
   ───────────────────────────────────────────────────────────── */

.ap__status {
  padding: 16px 0;
}

.ap__status--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 0;
  color: #888;
}

.ap__status-icon {
  font-size: 24px;
}

.ap__status-text {
  font-size: 13px;
}

/* Loading skeleton shimmer */
.ap__skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: ap-shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}

.ap__skeleton--kpi {
  height: 48px;
  width: 100%;
}

.ap__skeleton--section {
  height: 20px;
  width: 40%;
  margin-top: 16px;
}

.ap__skeleton--row {
  height: 16px;
  width: 100%;
}

@keyframes ap-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────────────────
   Messages
   ───────────────────────────────────────────────────────────── */

.ap__messages {
  margin-bottom: 12px;
}

.ap__message {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 6px;
}

.ap__message--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.ap__message--warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.ap__message--info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ─────────────────────────────────────────────────────────────
   KPI Strip
   ───────────────────────────────────────────────────────────── */

.ap__kpi-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.ap__kpi {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: #f8f9fa;
  border-radius: 6px;
}

.ap__kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
}

.ap__kpi-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.ap__kpi-moe {
  font-size: 10px;
  color: #aaa;
  margin-top: 1px;
}

/* ─────────────────────────────────────────────────────────────
   Sections
   ───────────────────────────────────────────────────────────── */

.ap__section {
  margin-bottom: 12px;
}

.ap__section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}

.ap__section-header:hover {
  background: #fafafa;
}

.ap__section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #555;
}

.ap__section-toggle {
  font-size: 12px;
  color: #999;
}

.ap__section--collapsed .ap__section-body,
.ap__section--collapsed .ap__chart {
  display: none;
}

/* ─────────────────────────────────────────────────────────────
   Rows
   ───────────────────────────────────────────────────────────── */

.ap__row {
  display: flex;
  align-items: baseline;
  padding: 4px 0;
  gap: 8px;
}

.ap__row--empty {
  color: #aaa;
  font-style: italic;
  font-size: 12px;
  padding: 8px 0;
}

.ap__row-label {
  flex: 1;
  font-size: 12px;
  color: #555;
}

.ap__row-value {
  font-size: 12px;
  font-weight: 500;
  color: #1a1a1a;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ap__row-moe {
  font-size: 10px;
  color: #aaa;
  text-align: right;
  min-width: 48px;
}

.ap__row--emphasis .ap__row-label,
.ap__row--emphasis .ap__row-value {
  font-weight: 600;
}

.ap__row--muted .ap__row-label,
.ap__row--muted .ap__row-value {
  color: #999;
}

/* ─────────────────────────────────────────────────────────────
   Catchment Table
   ───────────────────────────────────────────────────────────── */

.ap__ct {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 4px 0;
}

.ap__ct-th {
  font-weight: 500;
  color: #555;
  text-align: right;
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.ap__ct-th--label {
  text-align: left;
}

.ap__ct-td {
  text-align: right;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
  color: #1a1a1a;
}

.ap__ct-td--label {
  text-align: left;
  color: #555;
  font-weight: 400;
}

.ap__ct tbody tr:not(:last-child) .ap__ct-td {
  border-bottom: 1px solid #f5f5f5;
}

/* ─────────────────────────────────────────────────────────────
   Chart (simple stacked bar)
   ───────────────────────────────────────────────────────────── */

.ap__chart {
  margin: 8px 0;
}

.ap__chart-bars {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
}

.ap__chart-bar {
  min-width: 2px;
}

.ap__chart-bar:nth-child(1) { background: #3b82f6; }
.ap__chart-bar:nth-child(2) { background: #8b5cf6; }
.ap__chart-bar:nth-child(3) { background: #06b6d4; }
.ap__chart-bar:nth-child(4) { background: #d1d5db; }

.ap__chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.ap__chart-legend-item {
  font-size: 10px;
  color: #888;
}

/* ─────────────────────────────────────────────────────────────
   Empty state
   ───────────────────────────────────────────────────────────── */

.ap__empty {
  padding: 32px 16px;
  text-align: center;
  color: #888;
  font-size: 13px;
}
