/* Catcher — dashboard del usuario (/app).
   Usa los tokens de tokens.css (crema + coral). Solo layout + componentes
   propios del panel; los utilitarios vienen de tw.css / style.css. */

/* ─── Layout ───────────────────────────────────────────────────────────── */

.dash-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--catcher-bg);
}

.dash-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 14px;
  border-right: 1px solid var(--catcher-border);
  background: var(--catcher-surface);
  overflow-y: auto;
}

.dash-brand { margin-bottom: 14px; }

.dash-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--catcher-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.dash-nav-item:hover { background: var(--catcher-bg-2); color: var(--catcher-text); }
.dash-nav-item.is-active {
  background: var(--catcher-primary-soft);
  color: var(--catcher-primary-light);
  font-weight: 600;
}

.dash-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--catcher-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dash-sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--catcher-border);
  padding-top: 10px;
}

.dash-logout { color: var(--catcher-danger); }
.dash-logout:hover { background: rgba(179, 84, 62, 0.08); color: var(--catcher-danger); }

.dash-sync-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--catcher-text-dim);
}
.dash-sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--catcher-text-dim);
  flex-shrink: 0;
}
.dash-sync-chip.is-on .dash-sync-dot { background: var(--catcher-success); }
.dash-sync-chip.is-off .dash-sync-dot { background: var(--catcher-warning); }
.dash-sync-chip.is-error .dash-sync-dot { background: var(--catcher-danger); }

.dash-main { display: flex; flex-direction: column; min-width: 0; }

.dash-view {
  flex: 1;
  padding: 28px clamp(16px, 4vw, 48px) 64px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Banner de sync desactivada ───────────────────────────────────────── */

.dash-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px clamp(16px, 4vw, 48px) 0;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(166, 116, 71, 0.35);
  background: var(--catcher-secondary-soft);
  color: var(--catcher-text);
  font-size: 0.85rem;
  line-height: 1.5;
}
.dash-banner strong { font-weight: 700; }
.dash-banner.is-error {
  border-color: rgba(179, 84, 62, 0.4);
  background: rgba(179, 84, 62, 0.08);
}

/* ─── Componentes del panel ────────────────────────────────────────────── */

.dash-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 0;
  color: var(--catcher-text-muted);
  font-size: 0.9rem;
}
.dash-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--catcher-border);
  border-top-color: var(--catcher-primary);
  animation: dash-spin 0.8s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }

.dash-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--catcher-text-muted);
  font-size: 0.9rem;
  border: 1px dashed var(--catcher-border-strong);
  border-radius: var(--r-lg);
  background: var(--catcher-surface);
}
.dash-empty h3 { color: var(--catcher-text); margin-bottom: 6px; }

.dash-section-title {
  font-size: 1.6rem;
  color: var(--catcher-text);
  margin-bottom: 4px;
}
.dash-section-sub {
  font-size: 0.875rem;
  color: var(--catcher-text-muted);
  margin-bottom: 22px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.dash-stat {
  background: var(--catcher-surface);
  border: 1px solid var(--catcher-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.dash-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--catcher-text-dim);
}
.dash-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--catcher-text);
  margin-top: 4px;
}
.dash-stat .hint { font-size: 12px; color: var(--catcher-text-muted); margin-top: 2px; }

.dash-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--catcher-border);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-item:hover { background: var(--catcher-bg-2); }
.dash-list-item .title { font-weight: 600; color: var(--catcher-text); font-size: 0.9rem; }
.dash-list-item .meta { font-size: 12px; color: var(--catcher-text-muted); margin-top: 1px; }
.dash-list-item .trailing { margin-left: auto; text-align: right; font-size: 12px; color: var(--catcher-text-dim); flex-shrink: 0; }

.dash-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--catcher-bg-2);
  color: var(--catcher-text-muted);
  border: 1px solid var(--catcher-border);
}
.dash-chip.accent { background: var(--catcher-primary-soft); color: var(--catcher-primary-light); border-color: transparent; }
.dash-chip.ok { background: rgba(120, 140, 93, 0.14); color: var(--catcher-success); border-color: transparent; }

.dash-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.dash-toolbar input[type="search"],
.dash-toolbar input[type="date"],
.dash-toolbar select {
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--catcher-border-strong);
  background: var(--catcher-surface);
  color: var(--catcher-text);
  font-size: 0.875rem;
  min-width: 0;
}
.dash-toolbar input[type="search"] { flex: 1; min-width: 160px; }

.dash-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--catcher-border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.dash-tab {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--catcher-text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.dash-tab.is-active { color: var(--catcher-primary-light); border-bottom-color: var(--catcher-primary); }

.dash-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--catcher-primary-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0 14px;
}

.dash-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dash-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--catcher-text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--catcher-border);
}
.dash-table td { padding: 9px 10px; border-bottom: 1px solid var(--catcher-border); color: var(--catcher-text); }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table input[type="number"], .dash-table input[type="text"] {
  width: 76px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--catcher-border-strong);
  background: var(--catcher-surface);
  font-size: 0.85rem;
}
.dash-table input.wide { width: 100%; }

/* ─── Chat ─────────────────────────────────────────────────────────────── */

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  border: 1px solid var(--catcher-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--catcher-surface);
  min-height: 540px;
  max-height: calc(100vh - 220px);
}
.chat-peers { border-right: 1px solid var(--catcher-border); overflow-y: auto; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--catcher-bg);
}
.chat-bubble {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: var(--catcher-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--catcher-surface);
  border: 1px solid var(--catcher-border);
  color: var(--catcher-text);
  border-bottom-left-radius: 4px;
}
.chat-bubble .ts { display: block; font-size: 10.5px; opacity: 0.65; margin-top: 3px; }
.chat-bubble.share-card {
  border: 1px solid var(--catcher-border-strong);
  background: var(--catcher-surface-2);
  color: var(--catcher-text);
}
.chat-bubble.share-card.mine { background: var(--catcher-primary-soft); color: var(--catcher-text); }
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--catcher-border);
  background: var(--catcher-surface);
}
.chat-input-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--catcher-border-strong);
  background: var(--catcher-bg);
  font-size: 0.875rem;
}
.chat-day-sep {
  align-self: center;
  font-size: 11px;
  color: var(--catcher-text-dim);
  padding: 2px 12px;
  background: var(--catcher-surface);
  border: 1px solid var(--catcher-border);
  border-radius: var(--r-pill);
  margin: 8px 0 4px;
}

/* ─── Planificación — bloques/mesociclos ──────────────────────────────────
   3 tonos "soft" que tokens.css no define (solo primary/secondary tienen
   variante soft) para fases sin hue propio en el sistema de diseño global. */

.dash-view {
  --phase-danger-soft: rgba(179, 84, 62, 0.14);
  --phase-info-soft: rgba(106, 155, 204, 0.16);
  --phase-success-soft: rgba(120, 140, 93, 0.14);
  --phase-neutral-soft: rgba(143, 141, 132, 0.14);
}

.plb-timeline {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.plb-block-card {
  flex: 0 0 auto;
  width: 168px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--catcher-border);
  border-left: 4px solid var(--phase-c, var(--catcher-border-strong));
  background: var(--catcher-surface);
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.plb-block-card:hover { border-color: var(--phase-c, var(--catcher-border-strong)); }
.plb-block-card.is-active {
  box-shadow: var(--shadow-2);
  border-left-width: 4px;
  background: var(--phase-soft, var(--catcher-surface));
}

.plb-block-actions {
  display: flex;
  gap: 2px;
  margin: -2px -4px 4px;
}
.plb-block-actions button {
  padding: 2px 6px !important;
  font-size: 11px !important;
}

.plb-phase-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  background: var(--phase-soft, var(--catcher-bg-2));
  color: var(--phase-c, var(--catcher-text-muted));
}

.plb-phase-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--phase-c, var(--catcher-text-dim));
  flex-shrink: 0;
}

.plb-block-add {
  flex: 0 0 auto;
  width: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: 1px dashed var(--catcher-border-strong);
  padding: 10px 8px;
}
.plb-block-add select { width: 100%; }

/* ─── Planificación — calendario mensual ──────────────────────────────── */

.plb-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.plb-month-weekday-row,
.plb-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.plb-month-cell {
  min-height: 60px;
  padding: 5px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--catcher-border);
  background: var(--phase-soft, var(--catcher-surface));
  color: var(--catcher-text);
}
.plb-month-cell.is-outside { opacity: 0.35; }
.plb-month-cell.is-today { outline: 2px solid var(--catcher-primary); outline-offset: -1px; }

/* ─── Planificación — landmarks de volumen (MEV/MAV/MRV) ────────────────── */

.plb-volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.plb-volume-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--catcher-text-muted);
}

.plb-volume-track {
  position: relative;
  flex: 1;
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--catcher-bg-2);
}
.plb-volume-band { height: 100%; flex-shrink: 0; }
.plb-volume-band.is-below { background: transparent; }
.plb-volume-band.is-optimal { background: rgba(120, 140, 93, 0.35); }
.plb-volume-band.is-high { background: rgba(166, 116, 71, 0.35); }
.plb-volume-band.is-over { background: rgba(179, 84, 62, 0.3); }

.plb-volume-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  border-radius: 2px;
  background: var(--catcher-text);
  transform: translateX(-50%);
}
.plb-volume-marker.zone-below-mev { background: var(--catcher-text-dim); }
.plb-volume-marker.zone-mev-mav { background: var(--catcher-success); }
.plb-volume-marker.zone-mav-mrv { background: var(--catcher-warning); }
.plb-volume-marker.zone-above-mrv { background: var(--catcher-danger); }

.plb-volume-readout {
  width: 92px;
  flex-shrink: 0;
  text-align: right;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--catcher-text-dim);
}

.plb-volume-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.plb-volume-swatch.is-below { background: var(--catcher-bg-2); border: 1px solid var(--catcher-border-strong); }
.plb-volume-swatch.is-optimal { background: var(--catcher-success); }
.plb-volume-swatch.is-high { background: var(--catcher-warning); }
.plb-volume-swatch.is-over { background: var(--catcher-danger); }

/* ─── Planificación — variación de ejercicios ────────────────────────────── */

.plb-exercise-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--catcher-border);
}
.plb-exercise-row:first-of-type { border-top: none; }

.plb-swap-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.dash-chip.is-selectable {
  cursor: pointer;
  border: none;
}
.dash-chip.is-selectable:hover { background: var(--catcher-primary-soft); color: var(--catcher-primary-light); }

/* ─── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--catcher-border);
    overflow-x: auto;
  }
  .dash-brand { margin-bottom: 0; margin-right: 4px; }
  .dash-brand .brand-name { display: none; }
  .dash-nav { flex-direction: row; flex: 1; gap: 2px; }
  .dash-nav-item { padding: 8px 10px; white-space: nowrap; }
  .dash-nav-item span:not(.dash-badge) { display: none; }
  .dash-sidebar-footer { flex-direction: row; border-top: none; padding-top: 0; }
  .dash-sync-chip span:last-child { display: none; }
  .chat-layout { grid-template-columns: 1fr; max-height: none; }
  .chat-peers { display: none; }
  .chat-peers.is-open { display: block; }
  .chat-layout.show-peers .chat-pane { display: none; }
  .chat-layout.show-peers .chat-peers { display: block; border-right: none; }

  .plb-block-card { width: 138px; }
  .plb-month-cell { min-height: 44px; padding: 3px 4px; }
  .plb-volume-label { width: 72px; font-size: 11px; }
  .plb-volume-readout { width: 76px; font-size: 10.5px; }
}
