/* ============================================================
   ATLAS INTERACTIVE TEASER — self-contained, namespaced (.atl-*)
   Reuses master brand tokens from styles.css. Cyan-forward.
   Loaded AFTER premium.css. Only runs where [data-atl-teaser] exists.
   ============================================================ */

[data-atl-teaser] {
  --atl-cyan: var(--ent-cyan);
  --atl-green: #2fe6a0;
  --atl-amber: #ffb547;
  --atl-red: #ff5a6e;
}

/* ---- shell / device frame ---- */
.atl-shell {
  position: relative;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.04);
}
.atl-shell::before {
  content: '';
  position: absolute; inset: 0; z-index: -1; opacity: 0.6;
  background: radial-gradient(120% 90% at 50% -10%, rgba(0,212,255,0.16), transparent 55%);
  pointer-events: none;
}
@media (max-width: 560px) { .atl-shell { padding: var(--sp-3); } }

.atl-demo-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 0.5em;
}
.atl-demo-tag::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--atl-cyan); box-shadow: 0 0 10px var(--atl-cyan);
}
.atl-shell-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3);
}

/* ---- tab row ---- */
.atl-tabs {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
@media (max-width: 560px) {
  .atl-tabs {
    flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px;
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  }
}
.atl-tab {
  flex: 0 0 auto;
  font-family: var(--font-head); font-weight: 600;
  font-size: var(--text-sm); letter-spacing: 0.01em;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  cursor: pointer; white-space: nowrap;
  transition: color .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease;
}
.atl-tab:hover { color: var(--white); border-color: var(--border-strong); }
.atl-tab:focus-visible {
  outline: 2px solid var(--atl-cyan); outline-offset: 2px;
}
.atl-tab[aria-selected="true"] {
  color: var(--midnight);
  background: var(--ent-gradient);
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(0,212,255,0.35);
}

/* ---- panels ---- */
.atl-panels { position: relative; }
.atl-panel { display: none; }
.atl-panel.is-active {
  display: block;
  animation: atlFade .32s ease both;
}
@keyframes atlFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .atl-panel.is-active { animation: none; }
  .atl-pulse { animation: none !important; }
}

.atl-panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3);
}
.atl-panel-title {
  font-family: var(--font-head); font-weight: 700;
  font-size: var(--text-lg); color: var(--white);
}
.atl-stat {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-secondary); letter-spacing: 0.04em;
}
.atl-stat b { color: var(--atl-cyan); font-weight: 700; }

/* ---- generic mini button (square +/- and actions) ---- */
.atl-btn {
  font-family: var(--font-head); font-weight: 600; font-size: var(--text-sm);
  letter-spacing: 0.01em;
  border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(0,212,255,0.4);
  background: rgba(0,212,255,0.08); color: var(--atl-cyan);
  padding: 0.6rem 1.2rem;
  transition: background .2s ease, border-color .2s ease, transform .15s ease, box-shadow .2s ease;
}
.atl-btn:hover { background: rgba(0,212,255,0.16); border-color: var(--atl-cyan); }
.atl-btn:active { transform: translateY(1px); }
.atl-btn:focus-visible { outline: 2px solid var(--atl-cyan); outline-offset: 2px; }

.atl-step-btn {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; line-height: 1;
  border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--white);
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.atl-step-btn:hover { background: var(--surface-3); border-color: var(--atl-cyan); color: var(--atl-cyan); }
.atl-step-btn:active { transform: scale(0.92); }
.atl-step-btn:focus-visible { outline: 2px solid var(--atl-cyan); outline-offset: 2px; }
.atl-step-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============================================================
   WIDGET 1 — INVENTORY
   ============================================================ */
.atl-inv-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center; gap: var(--sp-2);
  padding: 0.85rem 1rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
}
.atl-inv-row.is-low { border-color: rgba(255,90,110,0.55); }
.atl-inv-name { min-width: 0; }
.atl-inv-name h4 {
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-base);
  color: var(--white); margin: 0; line-height: 1.3;
}
.atl-inv-sku {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-muted); letter-spacing: 0.04em;
}
.atl-inv-ctrl { display: inline-flex; align-items: center; gap: 0.6rem; }
.atl-inv-qty {
  font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700;
  color: var(--white); min-width: 2.4ch; text-align: center;
}
.atl-low-badge {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--atl-red);
  border: 1px solid rgba(255,90,110,0.5);
  background: rgba(255,90,110,0.1);
  border-radius: 999px; padding: 0.2rem 0.6rem;
  margin-top: 0.35rem;
  animation: atlGlowRed 1.6s ease-in-out infinite;
}
@keyframes atlGlowRed {
  0%,100% { box-shadow: 0 0 0 rgba(255,90,110,0); }
  50% { box-shadow: 0 0 14px rgba(255,90,110,0.5); }
}
@media (prefers-reduced-motion: reduce) { .atl-low-badge { animation: none; } }

/* ============================================================
   WIDGET 2 — JOBS (stage tracker)
   ============================================================ */
.atl-job-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); }
.atl-job-title { font-family: var(--font-head); font-weight: 600; font-size: var(--text-base); color: var(--white); margin-bottom: var(--sp-3); }
.atl-stages {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem; margin-bottom: var(--sp-3);
}
.atl-stage { text-align: center; position: relative; }
.atl-stage-dot {
  width: 40px; height: 40px; margin: 0 auto 0.5rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem;
  transition: all .35s ease;
}
.atl-stage.is-done .atl-stage-dot {
  border-color: var(--atl-cyan); background: var(--ent-gradient); color: var(--midnight);
}
.atl-stage.is-current .atl-stage-dot {
  border-color: var(--atl-cyan); color: var(--atl-cyan);
  background: rgba(0,212,255,0.12);
  animation: atlPulse 1.5s ease-in-out infinite;
}
.atl-pulse, .atl-stage.is-current .atl-stage-dot { will-change: box-shadow; }
@keyframes atlPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,212,255,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(0,212,255,0); }
}
.atl-stage-label { font-family: var(--font-head); font-size: var(--text-sm); color: var(--text-secondary); }
.atl-stage.is-current .atl-stage-label, .atl-stage.is-done .atl-stage-label { color: var(--white); }
.atl-stage-time {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--atl-cyan);
  margin-top: 0.25rem; min-height: 1em;
}
/* connector lines */
.atl-stage:not(:last-child) .atl-stage-dot::after {
  content: ''; position: absolute; top: 19px; left: 50%; width: 100%; height: 2px;
  background: var(--border-strong); z-index: -1;
}
.atl-stage.is-done:not(:last-child) .atl-stage-dot::after { background: var(--atl-cyan); }

/* ============================================================
   WIDGET 3 — FINANCE
   ============================================================ */
.atl-fin-grid { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.atl-fin-cost {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-2);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.7rem 1rem;
}
.atl-fin-cost label { font-family: var(--font-body); font-weight: 500; color: var(--white); font-size: var(--text-sm); display: flex; align-items: center; gap: 0.5rem; }
.atl-fin-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.atl-fin-ctrl { display: inline-flex; align-items: center; gap: 0.6rem; }
.atl-fin-val { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 700; color: var(--white); min-width: 7ch; text-align: right; }

.atl-fin-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
@media (max-width: 480px) { .atl-fin-summary { grid-template-columns: 1fr; } }
.atl-fin-kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; }
.atl-fin-kpi .k-label { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.atl-fin-kpi .k-val { font-family: var(--font-head); font-weight: 700; font-size: var(--text-lg); color: var(--white); margin-top: 0.25rem; }
.atl-fin-kpi .k-val.good { color: var(--atl-green); }
.atl-fin-kpi .k-val.warn { color: var(--atl-amber); }
.atl-fin-kpi .k-val.bad { color: var(--atl-red); }

.atl-bar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-1);
}
.atl-bar span { transition: width .3s ease; min-width: 0; }
.atl-bar .seg-labor { background: #00D4FF; }
.atl-bar .seg-materials { background: #0077FF; }
.atl-bar .seg-overhead { background: #8A2EFF; }
.atl-bar .seg-margin { background: rgba(47,230,160,0.85); }
.atl-bar .seg-margin.neg { background: rgba(255,90,110,0.85); }
.atl-bar-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.7rem; }
.atl-bar-legend span { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.atl-bar-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ============================================================
   WIDGET 4 — CHAT
   ============================================================ */
.atl-chat { display: flex; flex-direction: column; height: 320px; }
.atl-chat-thread {
  flex: 1 1 auto; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 0.5rem; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  scrollbar-width: thin;
}
.atl-msg { max-width: 80%; }
.atl-msg.me { align-self: flex-end; text-align: right; }
.atl-msg-meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.atl-msg-bubble {
  display: inline-block; text-align: left;
  font-size: var(--text-sm); line-height: 1.4; color: var(--white);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.55rem 0.8rem;
}
.atl-msg.me .atl-msg-bubble {
  background: rgba(0,212,255,0.14); border-color: rgba(0,212,255,0.4); color: var(--white);
}
.atl-chat-form { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.atl-input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--white);
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 0.6rem 1rem;
}
.atl-input::placeholder { color: var(--text-muted); }
.atl-input:focus-visible { outline: none; border-color: var(--atl-cyan); box-shadow: 0 0 0 2px rgba(0,212,255,0.25); }
.atl-typing { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); padding: 0.2rem 0.5rem; min-height: 1.2em; }

/* ============================================================
   WIDGET 5 — SAFETY / SDS
   ============================================================ */
.atl-sds-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-2);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 0.6rem;
}
@media (max-width: 480px) { .atl-sds-row { grid-template-columns: auto 1fr; } }
/* NFPA diamond */
.atl-nfpa { width: 56px; height: 56px; transform: rotate(45deg); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; flex: 0 0 auto; }
.atl-nfpa div { display: flex; align-items: center; justify-content: center; }
.atl-nfpa div span { transform: rotate(-45deg); font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; }
.atl-nfpa .n-fire { background: #e8443a; color: #fff; }     /* top - red - flammability */
.atl-nfpa .n-health { background: #2f6fe8; color: #fff; }   /* left - blue - health */
.atl-nfpa .n-react { background: #f2c81f; color: #111; }    /* right - yellow - reactivity */
.atl-nfpa .n-spec { background: #f4f4f4; color: #111; }     /* bottom - white - special */
.atl-sds-info h4 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-base); color: var(--white); margin: 0; }
.atl-sds-info .atl-sds-exp { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.atl-sds-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
@media (max-width: 480px) { .atl-sds-row .atl-sds-badges { grid-column: 1 / -1; align-items: flex-start; flex-direction: row; flex-wrap: wrap; } }
.atl-sds-badge {
  display: none;
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 999px; padding: 0.2rem 0.6rem;
}
.atl-sds-badge.show { display: inline-flex; }
.atl-sds-badge.expired { color: var(--atl-red); border: 1px solid rgba(255,90,110,0.5); background: rgba(255,90,110,0.1); animation: atlGlowRed 1.6s ease-in-out infinite; }
.atl-sds-badge.soon { color: var(--atl-amber); border: 1px solid rgba(255,181,71,0.5); background: rgba(255,181,71,0.1); }
.atl-sds-badge.ok { color: var(--atl-green); border: 1px solid rgba(47,230,160,0.5); background: rgba(47,230,160,0.1); }
.atl-qr { width: 30px; height: 30px; opacity: 0.7; flex: 0 0 auto; }

/* shared footer note + action row */
.atl-actions { margin-top: var(--sp-3); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.atl-note { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

/* Enterprise callout band */
.atl-cta {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0,212,255,0.35);
  background: linear-gradient(120deg, rgba(0,212,255,0.08), rgba(0,119,255,0.05));
  padding: var(--sp-6) var(--sp-4);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  box-shadow: 0 0 50px rgba(0,212,255,0.12);
}
.atl-cta::before {
  content: ''; position: absolute; inset: 0; opacity: 0.6; pointer-events: none;
  background: radial-gradient(80% 140% at 20% -20%, rgba(0,212,255,0.25), transparent 55%);
}
.atl-cta > * { position: relative; z-index: 1; }
.atl-cta h2 { font-size: var(--text-2xl); margin-bottom: 0.4rem; }
.atl-cta p { color: var(--text-secondary); max-width: 50ch; margin: 0; }
@media (max-width: 640px) { .atl-cta { padding: var(--sp-4); } }
