/* ============================================================
   ITS-VY (Färdskrivare & ITS)
   its-view.css — layout och komponenter för ITS-sidan och
   anslutningsguiden. Använder globala tokens från base.css.
   Rör ej regelmotor, GPS, tidslinje, lagring eller synk.
   ============================================================ */

/* ==========================================================
   CHROME-BYTE NÄR ITS ÄR AKTIV
   app-header döljs globalt i day-redesign.css.
   dt-header visas globalt.
   Enbart tabs döljs specifikt för ITS.
   ========================================================== */

:root:has(#itsView.active) .tabs { display: none !important; }

/* ==========================================================
   ITS VIEW – wrapper
   ========================================================== */

#itsView {
  padding-bottom: 48px;
}

/* ==========================================================
   TILLBAKA-RAD
   ========================================================== */

.its-back-bar {
  display: flex;
  align-items: center;
  padding: 4px 0 8px;
}

.its-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
  min-height: 44px;
  border-radius: var(--r-8);
  -webkit-tap-highlight-color: transparent;
}

.its-back-btn:hover {
  color: var(--text-strong);
}

.its-back-btn:active {
  opacity: 0.7;
}

/* ==========================================================
   HERO: TITEL + STATUS
   ========================================================== */

.its-hero {
  padding: 8px 0 20px;
}

.its-view-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--text-strong);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.its-status-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}

.its-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--muted-2);
  background: transparent;
  flex-shrink: 0;
  display: inline-block;
}

.its-status-dot--connected {
  border-color: var(--ok);
  background: var(--ok);
}

/* ==========================================================
   FÖRKLARING
   ========================================================== */

.its-explain {
  font-size: var(--fs-base);
  color: var(--text);
  line-height: var(--lh-normal);
  margin: 0 0 24px;
}

/* ==========================================================
   PRIMÄR KNAPP-BLOCK
   ========================================================== */

.its-action-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.its-connect-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: var(--fs-base);
  font-weight: 700;
  border-radius: var(--r-12);
  letter-spacing: 0.01em;
}

.its-support-text {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: var(--lh-normal);
  margin: 0;
}

/* ==========================================================
   SEKTIONER (Stödda färdskrivare / Så fungerar det)
   ========================================================== */

.its-section {
  margin-bottom: 28px;
}

.its-section-hd {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 12px;
}

/* ==========================================================
   ENHETSLISTA
   ========================================================== */

.its-device-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-12);
  background: var(--card-bg);
  overflow: hidden;
}

.its-device-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.its-device-item:last-child {
  border-bottom: none;
}

.its-device-make {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.its-device-model {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 500;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.its-device-other {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
}

.its-device-other .its-device-make {
  color: var(--text);
}

.its-device-other-note {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 400;
  line-height: var(--lh-normal);
}

/* ==========================================================
   SÅ FUNGERAR DET – stegslista
   ========================================================== */

.its-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: its-step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.its-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: var(--fs-sm);
  color: var(--text);
  line-height: var(--lh-normal);
  counter-increment: its-step;
}

.its-steps li::before {
  content: counter(its-step);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-bg);
  border: 1px solid var(--border-strong);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 800;
  margin-top: 1px;
}

/* ==========================================================
   ANSLUTNINGSGUIDE – overlay
   ========================================================== */

.its-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

.its-guide-overlay.open {
  pointer-events: auto;
}

.its-guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.its-guide-overlay.open .its-guide-backdrop {
  opacity: 1;
}

.its-guide-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  padding: 8px 20px max(28px, env(safe-area-inset-bottom, 28px));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  max-width: 640px;
  margin: 0 auto;
}

.its-guide-overlay.open .its-guide-sheet {
  transform: translateY(0);
}

.its-guide-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

/* ==========================================================
   STEGINDIKATOR
   ========================================================== */

.its-guide-steps-indicator {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 22px;
}

.its-step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.2s ease, width 0.2s ease;
}

.its-step-dot.active {
  background: var(--primary);
  width: 18px;
  border-radius: 3px;
}

.its-step-dot.done {
  background: var(--ok);
}

/* ==========================================================
   GUIDE-STEG
   ========================================================== */

.its-guide-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--text-strong);
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.its-guide-body {
  font-size: var(--fs-sm);
  color: var(--text);
  line-height: var(--lh-loose);
  margin: 0 0 20px;
}

/* ==========================================================
   GUIDE STEG 1 – Bluetooth-status
   ========================================================== */

.its-guide-bt-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-12);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  margin-bottom: 24px;
  min-height: 56px;
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

.its-guide-bt-status.bt-loading {
  color: var(--muted);
}

.its-bt-icon {
  font-size: 1.1rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.its-bt-supported    .its-bt-icon { color: var(--ok); }
.its-bt-unsupported  .its-bt-icon,
.its-bt-insecure-context .its-bt-icon { color: var(--danger); }

.its-guide-bt-status.its-bt-supported {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.its-guide-bt-status.its-bt-unsupported,
.its-guide-bt-status.its-bt-insecure-context {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.its-bt-msg {
  color: var(--text);
  font-weight: 500;
}

/* ==========================================================
   GUIDE STEG 2 – Tomt läge (inga enheter)
   ========================================================== */

.its-guide-empty-state {
  text-align: center;
  padding: 20px 0 24px;
}

.its-guide-empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--muted-2);
}

.its-guide-empty-text {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.its-guide-empty-hint {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: var(--lh-normal);
  margin: 0;
}

/* ==========================================================
   GUIDE-KNAPPAR
   ========================================================== */

.its-guide-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.its-guide-actions .btn {
  flex: 1;
  border-radius: var(--r-10, var(--r-8));
}

/* ==========================================================
   RESPONSIV – 390px mobil
   ========================================================== */

@media (max-width: 420px) {
  .its-guide-sheet {
    padding-left: 16px;
    padding-right: 16px;
  }

  .its-guide-actions {
    flex-direction: column;
  }
}
