/* ==========================================================================
   Interactive Product Demo — CSI Dry Eye
   ========================================================================== */

/* ---------- Section ---------- */
.demo {
  background: var(--color-bg-navy);
  padding: var(--space-5xl) var(--space-lg);
  position: relative;
  overflow: hidden;
}

/* Mesh gradient overlay (applied via pseudo-element since HTML has no mesh div) */
.demo::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(0, 60, 100, 0.5) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 70%, rgba(0, 40, 80, 0.4) 0%, transparent 50%);
  pointer-events: none;
}

/* ---------- Header ---------- */
.demo__header {
  text-align: center;
  position: relative;
  z-index: var(--z-content);
  max-width: 700px;
  margin-inline: auto;
  margin-bottom: var(--space-3xl);
}

.demo__eyebrow {
  display: inline-block;
  padding: var(--space-2xs) var(--space-md);
  background: rgba(250, 187, 0, 0.15);
  color: var(--color-accent);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-md);
}

.demo__title {
  color: #fff;
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
}

/* ---------- Tabs ---------- */
.demo__tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  position: relative;
  z-index: var(--z-content);
  margin-bottom: var(--space-xl);
}

.demo__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.demo__tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.demo__tab-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

.demo__tab--active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.demo__tab--active .demo__tab-number {
  background: var(--color-accent);
  color: var(--color-bg-navy);
}

/* ---------- Progress ---------- */
.demo__progress {
  max-width: 500px;
  margin-inline: auto;
  margin-bottom: var(--space-2xl);
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  position: relative;
  z-index: var(--z-content);
  overflow: hidden;
}

.demo__progress-bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.demo__progress-bar--animating {
  transform: scaleX(1) !important;
  transition: transform 6s linear;
}

/* ---------- Panels ---------- */
.demo__panel {
  display: none;
  position: relative;
  z-index: var(--z-content);
  max-width: 1000px;
  margin-inline: auto;
}

.demo__panel--active {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  animation: demo-fade-in 0.4s ease;
}

@media (min-width: 768px) {
  .demo__panel--active {
    grid-template-columns: 1fr 1fr;
  }
}

@keyframes demo-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Panel Content (text side) ---------- */
.demo__panel-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.demo__panel-title {
  color: #fff;
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
  margin-bottom: var(--space-md);
}

.demo__panel-desc {
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
}

/* Pre-fill indicator (Step 1) */
.demo__pre-fill-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  padding: var(--space-xs) var(--space-md);
  border: 2px dashed var(--color-status-teal);
  background: rgba(0, 131, 143, 0.08);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-status-cyan);
}

.demo__pre-fill-indicator svg {
  color: var(--color-status-teal);
  flex-shrink: 0;
}

/* ---------- Panel Mock (shared) ---------- */
.demo__panel-mock {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3), 0 10px 20px rgba(0, 0, 0, 0.15);
  padding: var(--space-lg);
  overflow: hidden;
}


/* ==========================================================================
   STEP 1 — Send & Collect
   ========================================================================== */

/* Mock Table */
.demo__mock-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.demo__mock-table-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-light);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.demo__mock-table-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  align-items: center;
  font-size: var(--fs-xs);
  border-top: 1px solid var(--color-border-light);
}

/* Status badges */
.demo__status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.demo__status--sent {
  color: var(--color-status-blue);
  background: rgba(21, 101, 192, 0.1);
}

.demo__status--completed {
  color: var(--color-status-green);
  background: rgba(46, 125, 50, 0.1);
}

.demo__status--pending {
  color: var(--color-status-amber);
  background: rgba(249, 168, 37, 0.1);
}

/* Actions row */
.demo__mock-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* Shared button styles */
.demo__mock-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.demo__mock-btn--primary {
  background: var(--color-status-teal);
  border: none;
  color: #fff;
}

.demo__mock-btn--primary:hover {
  background: var(--color-status-teal-dark);
}

.demo__mock-btn--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.demo__mock-btn--outline:hover {
  background: var(--color-bg-light);
}


/* ==========================================================================
   STEP 2 — Analyze & Flag
   ========================================================================== */

/* Medication flags */
.demo__mock-flags {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.demo__mock-flag {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--fs-sm);
}

.demo__mock-flag-name {
  font-weight: var(--fw-medium);
  color: var(--color-text);
}

.demo__mock-flag-badge {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.demo__mock-flag-badge--red {
  color: var(--color-error);
  background: rgba(220, 53, 69, 0.1);
}

/* Severity grid */
.demo__mock-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.demo__mock-grid-label {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  display: flex;
  align-items: center;
}

.demo__mock-grid-label--col {
  background: var(--color-bg-light);
  color: var(--color-text-light);
  justify-content: center;
  border-bottom: 1px solid var(--color-border-light);
  border-right: 1px solid var(--color-border-light);
}

.demo__mock-grid-label--col:last-of-type {
  border-right: none;
}

.demo__mock-grid-label--row {
  justify-content: flex-start;
  font-weight: var(--fw-medium);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
  border-right: 1px solid var(--color-border-light);
}

.demo__mock-grid-cell {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--color-border-light);
  border-right: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

.demo__mock-grid-cell:nth-child(4n) {
  border-right: none;
}

.demo__mock-grid-cell--active {
  background: var(--color-status-teal);
  color: #fff;
  font-weight: var(--fw-bold);
  animation: demo-cell-fill 0.4s ease;
}


/* ==========================================================================
   STEP 3 — Interpret & Treat
   ========================================================================== */

/* Findings */
.demo__mock-findings {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.demo__mock-finding {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--color-text);
  line-height: var(--lh-relaxed);
}

.demo__mock-finding-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-xs);
}

.demo__mock-finding-badge--amber {
  color: var(--color-status-orange);
  background: rgba(250, 187, 0, 0.12);
  border-left: 3px solid var(--color-accent);
}

.demo__mock-finding:has(.demo__mock-finding-badge--amber) {
  border-left: 3px solid var(--color-accent);
  background: rgba(250, 187, 0, 0.06);
}

.demo__mock-finding-badge--blue {
  color: var(--color-status-blue);
  background: rgba(21, 101, 192, 0.1);
}

.demo__mock-finding:has(.demo__mock-finding-badge--blue) {
  border-left: 3px solid var(--color-status-blue);
  background: rgba(21, 101, 192, 0.04);
}

/* Treatment tags */
.demo__mock-treatments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.demo__mock-treatment-tag {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(0, 131, 143, 0.1);
  color: var(--color-status-teal);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}


/* ==========================================================================
   STEP 4 — Export & Share
   ========================================================================== */

/* Export dropdown */
.demo__mock-export-dropdown {
  margin-bottom: var(--space-md);
}

.demo__mock-export-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-xs);
}

.demo__mock-export-options {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  display: flex;
  flex-direction: column;
}

.demo__mock-export-option {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--color-text);
  cursor: pointer;
}

.demo__mock-export-option--active {
  background: var(--color-status-teal);
  color: #fff;
  font-weight: var(--fw-semibold);
}

/* Export actions */
.demo__mock-export-actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* File rows */
.demo__mock-file-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.demo__mock-file-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--color-text);
}

.demo__mock-file-row svg {
  flex-shrink: 0;
  color: #DC3545;
}


/* ==========================================================================
   STEP 5 — Track & Compare
   ========================================================================== */

/* Chart */
.demo__mock-chart {
  margin-bottom: var(--space-lg);
  background: var(--color-bg-navy);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.demo__mock-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Comparison rows */
.demo__mock-comparison {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.demo__mock-comparison-row {
  display: grid;
  grid-template-columns: 100px 100px 1fr;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
}

.demo__mock-comparison-status {
  font-weight: var(--fw-semibold);
}

.demo__mock-comparison-count {
  color: var(--color-text-light);
}

.demo__mock-comparison-bar {
  height: 8px;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* Row variants */
.demo__mock-comparison-row--improved .demo__mock-comparison-status {
  color: var(--color-status-green);
}

.demo__mock-comparison-row--improved .demo__mock-comparison-bar {
  background: var(--color-status-green);
}

.demo__mock-comparison-row--unchanged .demo__mock-comparison-status {
  color: var(--color-status-amber);
}

.demo__mock-comparison-row--unchanged .demo__mock-comparison-bar {
  background: var(--color-status-amber);
}

.demo__mock-comparison-row--worsened .demo__mock-comparison-status {
  color: var(--color-error);
}

.demo__mock-comparison-row--worsened .demo__mock-comparison-bar {
  background: var(--color-error);
}


/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

/* Row / item slide-in */
@keyframes demo-item-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Flag badge pop */
@keyframes demo-flag-pop {
  0%   { opacity: 0; transform: scale(0.7); }
  70%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* Severity grid cell fill */
@keyframes demo-cell-fill {
  from {
    background: transparent;
    color: var(--color-text);
  }
  to {
    background: var(--color-status-teal);
    color: #fff;
  }
}

/* SVG line draw */
@keyframes demo-line-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Comparison bar grow */
@keyframes demo-bar-grow {
  from { width: 0; }
}

/* --- Staggered table rows (Step 1) --- */
.demo__panel--active .demo__mock-table-row {
  opacity: 0;
  animation: demo-item-in 0.35s ease forwards;
}

.demo__panel--active .demo__mock-table-row:nth-child(1) { animation-delay: 0.1s; }
.demo__panel--active .demo__mock-table-row:nth-child(2) { animation-delay: 0.2s; }
.demo__panel--active .demo__mock-table-row:nth-child(3) { animation-delay: 0.3s; }

/* --- Staggered medication flags (Step 2) --- */
.demo__panel--active .demo__mock-flag {
  opacity: 0;
  animation: demo-item-in 0.35s ease forwards;
}

.demo__panel--active .demo__mock-flag:nth-child(1) { animation-delay: 0.1s; }
.demo__panel--active .demo__mock-flag:nth-child(2) { animation-delay: 0.2s; }

/* Flag badge pop */
.demo__panel--active .demo__mock-flag-badge {
  opacity: 0;
  animation: demo-flag-pop 0.4s ease forwards 0.3s;
}

/* --- Staggered findings (Step 3) --- */
.demo__panel--active .demo__mock-finding {
  opacity: 0;
  animation: demo-item-in 0.35s ease forwards;
}

.demo__panel--active .demo__mock-finding:nth-child(1) { animation-delay: 0.1s; }
.demo__panel--active .demo__mock-finding:nth-child(2) { animation-delay: 0.2s; }

/* --- Staggered treatment tags (Step 3) --- */
.demo__panel--active .demo__mock-treatment-tag {
  opacity: 0;
  animation: demo-item-in 0.3s ease forwards;
}

.demo__panel--active .demo__mock-treatment-tag:nth-child(1) { animation-delay: 0.15s; }
.demo__panel--active .demo__mock-treatment-tag:nth-child(2) { animation-delay: 0.25s; }
.demo__panel--active .demo__mock-treatment-tag:nth-child(3) { animation-delay: 0.35s; }
.demo__panel--active .demo__mock-treatment-tag:nth-child(4) { animation-delay: 0.45s; }

/* --- Staggered file rows (Step 4) --- */
.demo__panel--active .demo__mock-file-row {
  opacity: 0;
  animation: demo-item-in 0.35s ease forwards;
}

.demo__panel--active .demo__mock-file-row:nth-child(1) { animation-delay: 0.1s; }
.demo__panel--active .demo__mock-file-row:nth-child(2) { animation-delay: 0.2s; }

/* --- Chart line draw (Step 5) --- */
.demo__panel--active .demo__mock-chart-svg polyline {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: demo-line-draw 1.5s ease forwards;
}

/* --- Comparison bar animation (Step 5) --- */
.demo__panel--active .demo__mock-comparison-bar {
  animation: demo-bar-grow 0.6s ease forwards;
}

.demo__panel--active .demo__mock-comparison-row:nth-child(1) .demo__mock-comparison-bar { animation-delay: 0.1s; }
.demo__panel--active .demo__mock-comparison-row:nth-child(2) .demo__mock-comparison-bar { animation-delay: 0.2s; }
.demo__panel--active .demo__mock-comparison-row:nth-child(3) .demo__mock-comparison-bar { animation-delay: 0.3s; }


/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .demo__panel--active {
    animation: none;
  }

  .demo__panel--active .demo__mock-table-row,
  .demo__panel--active .demo__mock-flag,
  .demo__panel--active .demo__mock-flag-badge,
  .demo__panel--active .demo__mock-finding,
  .demo__panel--active .demo__mock-treatment-tag,
  .demo__panel--active .demo__mock-file-row,
  .demo__panel--active .demo__mock-comparison-bar {
    opacity: 1;
    animation: none;
    transform: none;
  }

  .demo__progress-bar--animating {
    transition: none;
  }

  .demo__mock-grid-cell--active {
    animation: none;
  }

  .demo__panel--active .demo__mock-chart-svg polyline {
    animation: none;
    stroke-dashoffset: 0;
  }
}
