/* ══════════════════════════════════════════════════
   SJ Rail Demo — Styles
   ══════════════════════════════════════════════════ */

:root {
  --sj-green:        #2BAD53;
  --sj-green-dark:   #1E8C40;
  --sj-green-light:  rgba(43, 173, 83, 0.10);
  --sj-green-glow:   rgba(43, 173, 83, 0.30);

  --text-primary:    #1A1A1A;
  --text-secondary:  #6B6B6B;
  --text-tertiary:   #9E9E9E;

  --bg-app:          #F2F2F7;
  --bg-white:        #FFFFFF;
  --border:          #E5E5EA;
  --border-light:    #F0F0F5;

  --status-ok:       #1B8A3B;
  --status-ok-bg:    #E6F5EC;
  --status-warn:     #C85000;
  --status-warn-bg:  #FFF4EB;
  --status-orange:   #BF4800;
  --status-orange-bg:#FFF0E5;
  --status-red:      #C62828;
  --status-red-bg:   #FFEBEE;

  --nav-h:           68px;
  --status-h:        44px;
  --call-bar-h:      92px;
  --safe-b:          env(safe-area-inset-bottom, 0px);

  /* Cards sit between status bar and nav */
  --card-top:    calc(var(--status-h) + 8px);
  --card-bottom: calc(var(--nav-h) + var(--safe-b) + 8px);

  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;

  --shadow-card:  0 2px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-float: 0 8px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
body { background: #111; display: flex; justify-content: center; align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
* { scrollbar-width: none; } *::-webkit-scrollbar { display: none; }

/* ── App Shell ── */
.sj-app {
  position: relative;
  width: min(430px, 100vw);
  height: min(932px, 100vh);
  background: var(--bg-white);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: min(50px, 5vw);
  box-shadow: 0 28px 80px rgba(0,0,0,0.7);
}

/* ── Status Bar ── */
.status-bar {
  height: var(--status-h);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 0;
  color: white;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* Status bar goes dark when call view is visible */
.sj-app.is-calling .status-bar {
  color: var(--text-primary);
}

.status-time { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.status-icons { display: flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════════════════
   HOME VIEW
   ══════════════════════════════════════════════════ */

.home-view {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Northern lights fills the whole view */
  background-image: url('https://cdn.sj.se/images/hulddl9x/production/2634c057107a2a8c921966746d4ae0cdcdf60b5b-10095x4494.jpg?rect=1678,0,6741,4494&w=1920&h=1280&fm=webp&auto=format');
  background-size: cover;
  background-position: center 20%;
  /* pull up behind status bar */
  margin-top: calc(-1 * var(--status-h));
  padding-top: var(--status-h);
}

.home-view-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.30) 0%,
    rgba(0,0,0,0.10) 35%,
    rgba(0,0,0,0.55) 100%
  );
  pointer-events: none;
}

/* Logo — centred, prominent */
.sj-logo-img {
  display: block;
  height: 52px;
  width: auto;
  filter: brightness(0) invert(1);
  margin: 0 auto 20px;
  position: relative;
  z-index: 1;
  drop-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Top section: logo + greeting, vertically centred in available space */
.home-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.home-greeting {
  font-size: 15px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}

.home-tagline {
  font-size: 30px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-shadow: 0 2px 16px rgba(0,0,0,0.35);
}

/* Search card at the bottom */
.home-content {
  position: relative;
  z-index: 1;
  padding: 0 16px 16px;
  flex-shrink: 0;
}

/* ── Search Card ── */
.search-card {
  background: var(--bg-white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 4px 0 0;
  overflow: hidden;
}

.search-fields {
  padding: 0 16px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
}

.search-field-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-field-dot--from {
  background: var(--sj-green);
}

.search-field-dot--to {
  border: 2.5px solid var(--text-tertiary);
  background: transparent;
}

.search-field-placeholder {
  font-size: 16px;
  color: var(--text-tertiary);
}

.search-swap-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 0 1px;
}

.search-swap-track {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.search-swap-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-app);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.12s;
}
.search-swap-btn:active { background: var(--border); }

.search-meta-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-light);
}

.search-meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-app);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.search-go-btn {
  width: 100%;
  background: var(--sj-green);
  color: white;
  font-size: 17px;
  font-weight: 700;
  padding: 16px;
  letter-spacing: 0.01em;
  transition: background 0.12s;
}
.search-go-btn:active { background: var(--sj-green-dark); }


/* ══════════════════════════════════════════════════
   CALL VIEW
   ══════════════════════════════════════════════════ */

.call-view {
  flex: 1;
  display: none;
  flex-direction: column;
  background: var(--bg-white);
  overflow: hidden;
}

.sj-app.is-calling .call-view { display: flex; }
.sj-app.is-calling .home-view { display: none; }

/* Small SJ header during call */
.call-view-header {
  height: 52px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.sj-logo-call {
  height: 20px;
  width: auto;
  /* black logo on white bg — no filter needed */
}

.call-view-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.call-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sj-green);
  flex-shrink: 0;
}

.call-dot.is-speaking {
  animation: dot-speak .65s ease-in-out infinite alternate;
}

@keyframes dot-speak {
  from { opacity: .4; transform: scale(.8); }
  to   { opacity: 1;  transform: scale(1.3); }
}

.call-view-status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Transcript bubble area */
.transcript-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--call-bar-h) + var(--safe-b) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Transcript bubbles ── */
.t-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: bubble-in .28s cubic-bezier(.22,1,.36,1) both;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Bot — left, light grey */
.t-bubble--bot {
  align-self: flex-start;
  background: var(--bg-app);
  color: var(--text-primary);
  border-bottom-left-radius: 5px;
}

/* User — right, SJ green */
.t-bubble--user {
  align-self: flex-end;
  background: var(--sj-green);
  color: white;
  border-bottom-right-radius: 5px;
}

.t-bubble-sender {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
  opacity: 0.6;
}

/* ══════════════════════════════════════════════════
   OVERLAY CARDS
   ══════════════════════════════════════════════════ */

.overlay-card {
  position: absolute;
  top: var(--card-top);
  left: 8px;
  right: 8px;
  bottom: var(--card-bottom);
  z-index: 50;
  background: var(--bg-white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: calc(min(430px, 100vw) - 16px);
  margin: 0 auto;
}

.overlay-card--status  { z-index: 60; }
.overlay-card--action  { z-index: 70; }
.overlay-card--traffic { z-index: 65; }

/* Animations */
@keyframes card-in  { from { opacity:0; transform:translateY(36px) scale(.97); } to { opacity:1; transform:none; } }
@keyframes card-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateY(24px) scale(.97); } }

.overlay-card.is-visible { animation: card-in .38s cubic-bezier(.22,1,.36,1) forwards; }
.overlay-card.is-hiding  { animation: card-out .28s cubic-bezier(.4,0,1,1) forwards; }

.card-handle-bar {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 14px auto 0;
  flex-shrink: 0;
}

.card-close-btn {
  position: absolute;
  top: 10px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  z-index: 2;
  transition: background .14s;
}
.card-close-btn:hover { background: var(--border); }

.card-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.card-eyebrow {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sj-green);
  background: var(--sj-green-light);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 18px;
}
.card-eyebrow--status  { color: var(--status-warn);   background: var(--status-warn-bg); }
.card-eyebrow--action  { color: var(--status-ok);     background: var(--status-ok-bg); }
.card-eyebrow--traffic { color: var(--status-orange); background: var(--status-orange-bg); }

/* ── Overview card inner ── */
.ov-booking-ref   { font-size: 12px; color: var(--text-tertiary); font-weight: 500; margin-bottom: 4px; }
.ov-passenger     { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 18px; letter-spacing: -.01em; }

.route-box {
  background: var(--bg-app);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 14px;
}

.route-box-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.route-end { display: flex; flex-direction: column; gap: 3px; min-width: 82px; }
.route-end--right { align-items: flex-end; text-align: right; }
.route-t { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -0.02em; }
.route-city { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.route-plat { font-size: 12px; color: var(--text-tertiary); }

.route-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: 5px;
}
.route-vline { width: 1.5px; height: 12px; background: var(--border); border-radius: 1px; }

.train-chip {
  display: flex; align-items: center; gap: 4px;
  background: white; border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 9px;
  font-size: 11px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap;
}
.train-chip svg { color: var(--sj-green); }

.route-dur { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }

.ticket-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.ticket-tile {
  background: var(--bg-app);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.tt-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.tt-value { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.ticket-tile--wide { grid-column: span 2; }

/* ── Status card inner ── */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 20px; padding: 9px 16px;
  font-size: 15px; font-weight: 700;
  margin-bottom: 18px;
}
.status-pill--ok     { background: var(--status-ok-bg);     color: var(--status-ok); }
.status-pill--warn   { background: var(--status-warn-bg);   color: var(--status-warn); }
.status-pill--orange { background: var(--status-orange-bg); color: var(--status-orange); }
.status-pill--red    { background: var(--status-red-bg);    color: var(--status-red); }

.status-pill-dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: blink 1.3s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

.info-rows {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 14px;
}
.info-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-secondary); }
.info-row-val   { font-weight: 600; color: var(--text-primary); }
.info-row-val--warn { color: var(--status-warn); }
.info-row-val--ok   { color: var(--status-ok); }

.reason-box {
  background: var(--status-warn-bg);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 13px; color: var(--status-warn);
  line-height: 1.5;
}

/* ── Action card inner ── */
.act-icon {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: var(--status-ok-bg);
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 16px;
  color: var(--status-ok);
}

.act-title   { font-size: 24px; font-weight: 800; color: var(--text-primary); text-align: center; margin-bottom: 6px; letter-spacing: -0.02em; }
.act-sub     { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 22px; line-height: 1.4; }
.act-note    { background: var(--status-ok-bg); border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; color: var(--status-ok); line-height: 1.5; margin-top: 14px; }
.act-note--amber { background: var(--status-warn-bg); color: var(--status-warn); }

.refund-display {
  background: var(--bg-app);
  border-radius: var(--r-md);
  padding: 20px;
  text-align: center;
  margin-bottom: 14px;
}
.refund-lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-tertiary); margin-bottom: 6px; }
.refund-amt { font-size: 40px; font-weight: 800; color: var(--status-ok); letter-spacing: -0.03em; }

.comp-ref-row {
  background: var(--bg-app); border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.comp-ref-lbl { font-size: 13px; color: var(--text-tertiary); }
.comp-ref-val { font-size: 16px; font-weight: 700; color: var(--text-primary); font-family: monospace; }

/* ── Traffic card inner ── */
.traffic-route-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 14px; }
.disruption-list { display: flex; flex-direction: column; gap: 10px; }
.disruption-item {
  background: var(--bg-app);
  border-radius: var(--r-md);
  padding: 14px 16px;
  border-left: 3px solid var(--status-warn);
}
.disruption-item--severe { border-left-color: var(--status-red); }
.disruption-item--minor  { border-left-color: var(--status-ok); }
.disruption-title  { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.disruption-detail { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ══════════════════════════════════════════════════
   BOTTOM NAVIGATION
   ══════════════════════════════════════════════════ */

.bottom-nav {
  height: calc(var(--nav-h) + var(--safe-b));
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: flex-start;
  padding: 8px 0 0;
  padding-bottom: var(--safe-b);
  flex-shrink: 0;
  z-index: 30;
}

.nav-tab {
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  gap: 4px;
  padding: 0 2px;
  color: var(--text-tertiary);
  font-size: 10px; font-weight: 500;
  transition: color .15s;
  min-width: 0;
}
.nav-tab span { letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
.nav-tab.is-active { color: var(--sj-green); }

.nav-sigrid { position: relative; color: var(--sj-green); }
.nav-sigrid span { font-size: 10px; font-weight: 700; color: var(--sj-green); }

.sigrid-btn-outer {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--sj-green);
  box-shadow: 0 4px 16px var(--sj-green-glow);
  display: flex; align-items: center; justify-content: center;
  position: relative; top: -18px;
  margin-bottom: -14px;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
}

.nav-sigrid:active .sigrid-btn-outer { transform: scale(.92); }

.sigrid-btn-outer.is-calling {
  animation: sig-pulse 1.8s ease-in-out infinite;
}

@keyframes sig-pulse {
  0%,100% { box-shadow: 0 4px 16px var(--sj-green-glow); }
  50%      { box-shadow: 0 4px 28px var(--sj-green-glow), 0 0 0 10px rgba(43,173,83,.12); }
}

.sigrid-btn-inner { display: flex; align-items: center; justify-content: center; }

/* ══════════════════════════════════════════════════
   CALL BAR
   ══════════════════════════════════════════════════ */

.call-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--call-bar-h) + var(--safe-b));
  background: #1C1C1E;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  padding-bottom: var(--safe-b);
  z-index: 40;
  transform: translateY(100%);
  transition: transform .4s cubic-bezier(.22,1,.36,1);
}

.call-bar.is-visible { transform: translateY(0); }

.call-ctrl-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
  transition: background .14s, transform .1s;
}
.call-ctrl-btn:active { transform: scale(.9); }
.call-ctrl-btn.is-muted { background: rgba(255,255,255,.28); color: rgba(255,255,255,.5); }

.call-ctrl-btn--end { background: #E53935; }
.call-ctrl-btn--end:active { background: #C62828; }

.call-bar-center {
  flex: 1; min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.call-bar-sigrid-row {
  display: flex; align-items: center; gap: 6px;
}

.call-bar-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sj-green);
  flex-shrink: 0;
  animation: dot-speak .65s ease-in-out infinite alternate;
}

.call-bar-name {
  font-size: 15px;
  font-weight: 700;
  color: white;
}

.call-bar-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

/* ── Animate-in helper ── */
@keyframes fade-up { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
.anim { animation: fade-up .35s cubic-bezier(.22,1,.36,1) both; }
.anim-1 { animation-delay: .06s; }
.anim-2 { animation-delay: .12s; }
.anim-3 { animation-delay: .18s; }
.anim-4 { animation-delay: .22s; }

/* ── Full-screen on real phones ── */
@media (max-width: 430px) {
  .sj-app { border-radius: 0; box-shadow: none; width: 100vw; height: 100dvh; }
  body { background: white; }
}
