/* =========================================================
   HERO DASHBOARD
   Scoped styles for the hero-dashboard preview block.
   Markup: <div class="preview fade d4">…</div>
   Relies on .fade / .fade.d4 keyframes in styles.css.
   ========================================================= */

.hero-dashboard {
  position: relative;
  margin: 24px auto 0;
  max-width: 1140px;
  padding: 0 12px;
}
.hero-dashboard img { width: 100%; height: auto; display: block; }

.preview {
  position: relative;
  margin: 32px auto 0;
  border-radius: var(--b-radius-25);
  background: var(--gray-50);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.02),
    0 24px 48px -24px rgb(8 8 48 / 10%),
    0 50px 50px -60px rgba(8, 8, 48, 0.10);
  overflow: hidden;
}
.preview-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}
.preview-bar .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--gray-300);
}
.preview-bar .url {
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gray-600);
  background: var(--gray-150);
  padding: 6px 16px;
  border-radius: var(--b-radius-5);
}
.preview-body {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 32px;
  padding: 28px;
  min-height: 460px;
}

/* Sidebar */
.side-nav {
  border-right: none;
  padding-right: 0;
}
.side-nav .label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-600);
  font-weight: var(--fw-medium);
  margin-bottom: 12px;
  padding-left: 12px;
  text-align: left;
}
.side-nav .group { margin-bottom: 28px; }
.side-nav .item {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--gray-800);
  border-radius: var(--b-radius-8);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  background: transparent;
  border: 1px solid transparent;
  line-height: 1em;
}
.side-nav .item.active {
  background: #fff;
  border-color: var(--gray-200);
  color: var(--ink);
  font-weight: var(--fw-medium);
  box-shadow: 0 1px 2px rgba(8,8,48,0.04);
}
.side-nav .item .ico {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--gray-400);
  border: 1px solid var(--gray-400);
  flex-shrink: 0;
  position: relative;
}
.side-nav .item.active .ico { background: var(--ink); }
.side-nav .item .ico-filled {
  background: var(--ink);
  border-color: var(--ink);
}
.side-nav .item .ico-check {
  background: var(--gray-400);
  border-color: var(--gray-400);
}
.side-nav .item.skel {
  padding: 9px 12px;
  gap: 12px;
}
.side-nav .item.skel .ico {
  background: var(--gray-200);
  border: none;
}
.side-nav .item.skel .line {
  display: block;
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--b-radius-full);
  max-width: 70%;
}
.side-nav .item.skel .line.short { max-width: 45%; }

/* Panel header */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.panel-title {
  font-size: 18px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.018em;
  color: var(--ink);
}
.panel-title small {
  font-weight: var(--fw-regular);
  color: var(--ink-3);
  margin-left: 6px;
  font-size: 12px;
}
.panel-actions { display: flex; gap: 8px; }
.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--b-radius-8);
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-status .pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5BD5FF;
  box-shadow: 0 0 0 0 rgba(135,223,255,0.6);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(135,223,255,0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(135,223,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(135,223,255,0); }
}

/* Stat cards */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--b-radius-10);
}
.stat .k {
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 10px;
}
.stat .v {
  font-size: 32px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 8px;
}
.stat .d {
  font-size: 12px;
  font-family: var(--mono);
  color: #10B981;
  margin-top: 2px;
}
.stat .arrow-up,
.stat .arrow-down { color: #10B981; }

/* Flow cards */
.flow {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--b-radius-15);
  padding: 22px;
  overflow: hidden;
}
.flow-title {
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}
.flow-steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
}
.fstep {
  flex: 1;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--b-radius-10);
  font-size: 12px;
  text-align: center;
}
.fstep b {
  display: block;
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--ink);
  margin-bottom: 4px;
}
.fstep span {
  display: block;
  font-size: 11px;
  color: var(--gray-700);
  font-family: var(--mono);
}
.fstep.done { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fstep.done span { color: rgba(255,255,255,0.5); }
.fstep.active {
  background: var(--gray-200);
  border-color: transparent;
}
.fstep.skel-step {
  background: var(--gray-200);
  border-color: transparent;
  min-height: 52px;
}
.farrow {
  color: var(--gray-500);
  font-size: 14px;
  align-self: center;
}

/* External rules: 4-col grid with fade-out */
.flow.external-rules {
  position: relative;
  padding-bottom: 0;
  margin-bottom: -28px;
  border: 1px solid var(--gray-200);
  border-bottom: 0;
  border-radius: var(--b-radius-15) 14px 0 0;
}
.flow.external-rules .flow-steps {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.flow.external-rules .skel-step {
  min-height: 90px;
  background: linear-gradient(180deg, var(--gray-200) 0%, var(--gray-100) 100%);
  border-radius: 12px;
}
.flow.external-rules::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60%;
  background: linear-gradient(180deg, rgba(250,250,250,0) 0%, var(--gray-50) 80%);
  pointer-events: none;
}

/* Subtle shimmer on skeleton rows */
.side-nav .item.skel .line,
.flow.external-rules .skel-step {
  background-image: linear-gradient(
    90deg,
    rgba(236,236,242,0) 0%,
    rgba(255,255,255,0.6) 50%,
    rgba(236,236,242,0) 100%
  ), linear-gradient(180deg, var(--gray-200) 0%, var(--gray-200) 100%);
  background-size: 200% 100%, 100% 100%;
  background-repeat: no-repeat;
  animation: skel-shimmer 2.2s ease-in-out infinite;
}
.flow.external-rules .skel-step {
  background-image: linear-gradient(
    90deg,
    rgba(236,236,242,0) 0%,
    rgba(255,255,255,0.55) 50%,
    rgba(236,236,242,0) 100%
  ), linear-gradient(180deg, var(--gray-200) 0%, var(--gray-100) 100%);
}
@keyframes skel-shimmer {
  0%   { background-position: -150% 0, 0 0; }
  100% { background-position: 150% 0, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .side-nav .item.skel .line,
  .flow.external-rules .skel-step { animation: none; }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* Tablet: collapse to single column, side-nav becomes top strip */
@media (max-width: 960px) {
  .hero-dashboard { padding: 0 8px; }
  .preview { border-radius: var(--b-radius-15); }
  .preview-bar { border-top-left-radius: 16px; border-top-right-radius: 16px; }
  .preview-body {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
    min-height: 0;
  }
  .side-nav {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0 0 16px;
  }
  .side-nav .group { margin-bottom: 16px; }
  .side-nav .group:last-child { margin-bottom: 0; }
  /* Skeleton items get noisy on mobile — drop the lower half */
  .side-nav .group:last-child .item.skel { display: none; }
  .flow-steps { gap: 8px; }
  .stat-row { gap: 8px; }
  .stat .v { font-size: 26px; }
}

/* Mobile: stack flow vertically, compact stats, hide URL chrome */
@media (max-width: 640px) {
  .hero-dashboard { padding: 0 4px; margin-top: 16px; }
  .preview {
    border-radius: var(--b-radius-15);
    margin-top: 20px;
  }
  .preview-bar {
    padding: 10px 12px;
    gap: 5px;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
  }
  .preview-bar .dot { width: 9px; height: 9px; }
  .preview-bar .url {
    font-size: 10px;
    padding: 4px 10px;
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preview-body {
    padding: 16px;
    gap: 16px;
  }

  /* Side-nav becomes a horizontal scrolling chip row */
  .side-nav {
    padding: 0 0 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav .group { display: none; }
  .side-nav .group:first-child {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    flex-wrap: nowrap;
  }
  .side-nav .label { display: none; }
  .side-nav .item {
    margin-bottom: 0;
    padding: 7px 12px;
    font-size: 12px;
    border: 1px solid var(--line);
    border-radius: var(--b-radius-full);
    background: #fff;
    flex-shrink: 0;
  }
  .side-nav .item .ico { width: 12px; height: 12px; }
  .side-nav .item.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
    box-shadow: none;
  }
  .side-nav .item.active .ico { background: #fff; border-color: #fff; }

  /* Panel header wraps */
  .panel-head {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
  }
  .panel-title { font-size: 15px; }
  .panel-actions { gap: 6px; }
  .chip { font-size: 10px; padding: 4px 9px; }

  /* Stat cards — keep 3 columns but tighten */
  .stat-row { gap: 6px; margin-bottom: 12px; }
  .stat { padding: 10px 8px; border-radius: var(--b-radius-8); }
  .stat .k { font-size: 10px; margin-bottom: 4px; }
  .stat .v { font-size: 18px; letter-spacing: -0.02em; margin-bottom: 2px; }
  .stat .d { font-size: 10px; }

  /* Flow stacks vertically with rotated arrows */
  .flow { padding: 14px; border-radius: 12px; }
  .flow-title { font-size: 11px; margin-bottom: 12px; }
  .flow-steps {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .fstep { padding: 10px 12px; }
  .fstep b { font-size: 13px; }
  .fstep span { font-size: 10px; }
  .farrow {
    transform: rotate(90deg);
    justify-self: center;
    font-size: 12px;
  }

  /* External rules — 2 columns instead of 4 */
  .flow.external-rules .flow-steps {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .flow.external-rules .skel-step { min-height: 70px; }
}

/* Small mobile: single-column external rules, tighter still */
@media (max-width: 380px) {
  .stat .v { font-size: 16px; }
  .stat .k { font-size: 9px; }
  .flow.external-rules .skel-step { min-height: 56px; }
  .preview-bar .url { display: none; }
  .preview-bar { justify-content: flex-start; }
}
