/* ============ TryggMat — futuristic mobile-first design ============ */

:root {
  --bg-0: #060913;
  --bg-1: #0b1120;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --stroke: rgba(148, 163, 184, 0.18);
  --text: #e6edf7;
  --text-dim: #94a3b8;
  --teal: #2dd4bf;
  --teal-deep: #0d9488;
  --violet: #8b5cf6;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 20px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }

/* The app is a fixed viewport: the page itself never scrolls (no rubber-band
   on mobile). Views that overflow scroll internally instead. */
body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text);
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* --- Aurora background --- */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 70%);
}
.aurora::before, .aurora::after {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.35; will-change: transform;
}
.aurora::before {
  width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax;
  background: radial-gradient(circle, var(--teal-deep), transparent 65%);
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
  width: 55vmax; height: 55vmax; right: -22vmax; bottom: -25vmax;
  background: radial-gradient(circle, var(--violet), transparent 65%);
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(12vmax, 8vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-10vmax, -8vmax) scale(1.1); } }

/* --- Layout --- */
.app {
  max-width: 480px; margin: 0 auto;
  height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.view { display: none; animation: viewIn 0.42s cubic-bezier(0.22, 1, 0.36, 1); }
.view.active {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 18px 96px;
}
/* The scanner is a fixed window: nothing scrolls, the camera fills the space. */
#view-scan.active { overflow: hidden; padding-bottom: 96px; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* --- Typography --- */
h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px; }
.muted { color: var(--text-dim); font-size: 0.92rem; line-height: 1.5; }

.gradient-text {
  background: linear-gradient(100deg, var(--teal) 10%, #a78bfa 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* --- Brand header --- */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand img { width: 46px; height: 46px; filter: drop-shadow(0 0 14px rgba(45, 212, 191, 0.45)); }
.brand .name { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.brand .tag { font-size: 0.75rem; color: var(--text-dim); letter-spacing: 0.14em; text-transform: uppercase; }

.hero { text-align: center; padding: 26px 0 12px; }
.hero img { width: 108px; height: 108px; filter: drop-shadow(0 0 30px rgba(45, 212, 191, 0.5)); animation: float 5s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero h1 { margin: 16px 0 8px; font-size: 2rem; }
.hero p { color: var(--text-dim); max-width: 320px; margin: 0 auto; line-height: 1.55; }

/* --- Glass cards --- */
.card {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin-bottom: 16px;
}

/* --- Forms --- */
label { display: block; font-size: 0.85rem; color: var(--text-dim); margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; padding: 13px 16px; font-size: 1rem; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--stroke);
  border-radius: 14px; outline: none; font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 18px; margin-top: 16px;
  font-size: 1rem; font-weight: 700; font-family: var(--font);
  color: #04211d; background: linear-gradient(100deg, var(--teal), #6ee7b7);
  border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.28);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.secondary {
  background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--stroke); box-shadow: none;
}
.btn.ghost { background: transparent; color: var(--text-dim); box-shadow: none; border: none; margin-top: 8px; font-weight: 600; }
.btn.google { background: #fff; color: #1f2937; box-shadow: 0 6px 18px rgba(255,255,255,0.12); }
.btn.google svg { width: 20px; height: 20px; }

.switch-link { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--text-dim); }
.switch-link a { color: var(--teal); text-decoration: none; font-weight: 600; cursor: pointer; }

.notice {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.5;
  display: none;
}
.notice.show { display: block; animation: viewIn 0.3s ease; }
.notice.error { background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.35); color: #fecaca; }
.notice.success { background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.35); color: #a7f3d0; }
.notice a { color: var(--teal); word-break: break-all; }

/* --- Profile chips --- */
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 10px; border-radius: 16px; cursor: pointer; text-align: center;
  background: var(--glass); border: 1.5px solid var(--stroke);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-size: 0.92rem; font-weight: 600; user-select: none;
}
.chip .emoji { font-size: 1.6rem; }
.chip:hover { transform: translateY(-2px); }
.chip.selected {
  border-color: var(--teal); background: rgba(45, 212, 191, 0.12);
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.18);
}
.chip-grid.small .chip { padding: 10px 8px; font-size: 0.82rem; flex-direction: row; justify-content: center; }
/* Full-width chip spanning both columns (e.g. "Allmän hälsa" under the 2x2 grid) */
.chip.wide { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; padding: 14px 10px; }
.chip.wide .emoji { font-size: 1.35rem; }

/* --- Scanner --- */
.scan-stage {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; border: 1px solid var(--stroke);
  flex: 1; min-height: 0;
}
.scan-stage video { width: 100% !important; height: 100% !important; object-fit: cover; }
#reader { width: 100%; height: 100%; }
#reader video { object-fit: cover; }

.scan-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.scan-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 78%; height: 34%;
}
.scan-frame i {
  position: absolute; width: 30px; height: 30px; border: 3px solid var(--teal);
  filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.8));
}
.scan-frame i:nth-child(1) { left: 0; top: 0; border-right: none; border-bottom: none; border-radius: 10px 0 0 0; }
.scan-frame i:nth-child(2) { right: 0; top: 0; border-left: none; border-bottom: none; border-radius: 0 10px 0 0; }
.scan-frame i:nth-child(3) { left: 0; bottom: 0; border-right: none; border-top: none; border-radius: 0 0 0 10px; }
.scan-frame i:nth-child(4) { right: 0; bottom: 0; border-left: none; border-top: none; border-radius: 0 0 10px 0; }
.scan-line {
  position: absolute; left: 6%; right: 6%; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.9);
  animation: scanline 2.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes scanline { 0%, 100% { top: 8%; } 50% { top: 88%; } }

.scan-hint {
  position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  font-size: 0.85rem; color: rgba(230, 237, 247, 0.85); text-shadow: 0 1px 4px #000;
}

.manual-row { display: flex; gap: 10px; margin-top: 14px; }
.manual-row input { flex: 1; }
.manual-row .btn { width: auto; margin-top: 0; padding: 13px 20px; }

/* --- Result verdict --- */
.verdict-wrap { text-align: center; padding: 10px 0 4px; }
.verdict-ring {
  position: relative; width: 168px; height: 168px; margin: 0 auto 14px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.verdict-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.verdict-ring circle.track { fill: none; stroke: rgba(148, 163, 184, 0.15); stroke-width: 9; }
.verdict-ring circle.arc {
  fill: none; stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 471; stroke-dashoffset: 471;
  animation: ringFill 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards;
}
@keyframes ringFill { to { stroke-dashoffset: 0; } }
.verdict-ring .emoji { font-size: 3.4rem; animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.55s both; }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

.verdict-ring.green circle.arc { stroke: var(--green); filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.7)); }
.verdict-ring.yellow circle.arc { stroke: var(--yellow); filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.7)); }
.verdict-ring.red circle.arc { stroke: var(--red); filter: drop-shadow(0 0 10px rgba(248, 113, 113, 0.7)); }
.verdict-ring.unknown circle.arc { stroke: var(--text-dim); }

.verdict-title { font-size: 1.5rem; font-weight: 800; }
.verdict-title.green { color: var(--green); }
.verdict-title.yellow { color: var(--yellow); }
.verdict-title.red { color: var(--red); }
.verdict-title.unknown { color: var(--text-dim); }

.product-head { display: flex; gap: 14px; align-items: center; }
.product-head img {
  width: 64px; height: 64px; object-fit: contain; border-radius: 12px;
  background: rgba(255, 255, 255, 0.9); padding: 4px; flex-shrink: 0;
}
.product-head .info { min-width: 0; }
.product-head .info b { display: block; font-size: 1.05rem; }

.reason {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  animation: viewIn 0.4s ease both;
}
.reason:last-child { border-bottom: none; }
.reason .dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.reason .dot.green { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
.reason .dot.yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(251, 191, 36, 0.7); }
.reason .dot.red { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.7); }
.reason b { font-size: 0.86rem; display: block; margin-bottom: 2px; }
.reason p { font-size: 0.9rem; color: var(--text-dim); line-height: 1.5; }

/* --- History --- */
.history-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1); cursor: pointer;
}
.history-item:last-child { border-bottom: none; }
.history-item .vdot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.vdot.green { background: var(--green); } .vdot.yellow { background: var(--yellow); }
.vdot.red { background: var(--red); } .vdot.unknown { background: var(--text-dim); }
.history-item .hinfo { flex: 1; min-width: 0; }
.history-item .hinfo b { font-size: 0.95rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .hinfo span { font-size: 0.78rem; color: var(--text-dim); }

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: none; justify-content: space-around; align-items: center;
  max-width: 480px; margin: 0 auto; padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 15, 28, 0.82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--stroke);
  border-radius: 22px 22px 0 0;
}
.bottom-nav.show { display: flex; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-dim); font-family: var(--font);
  font-size: 0.68rem; font-weight: 600; cursor: pointer; padding: 6px 14px; border-radius: 12px;
  transition: color 0.2s;
}
.nav-btn .ico { font-size: 1.35rem; transition: transform 0.2s; }
.nav-btn.active { color: var(--teal); }
.nav-btn.active .ico { transform: translateY(-2px) scale(1.12); }
.nav-btn.scan-main {
  background: linear-gradient(120deg, var(--teal), var(--violet));
  color: #fff; border-radius: 50%; width: 58px; height: 58px; padding: 0;
  margin-top: -26px; box-shadow: 0 8px 24px rgba(45, 212, 191, 0.4);
  justify-content: center;
}
.nav-btn.scan-main .ico { font-size: 1.5rem; }
.nav-btn.scan-main span:not(.ico) { display: none; }

/* --- Utility --- */
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 2px; color: var(--text-dim); font-size: 0.8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2); border-top-color: var(--teal);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 7px; animation: pulse 1.8s ease infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); } 50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } }

/* --- Premium plans --- */
.plan-card {
  position: relative;
  background: var(--glass); border: 1.5px solid var(--stroke);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px;
  cursor: pointer; transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.plan-card:hover { transform: translateY(-2px); border-color: var(--teal); }
.plan-card.featured {
  border-color: var(--teal);
  background: rgba(45, 212, 191, 0.08);
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.15);
}
.plan-card .plan-badge {
  position: absolute; top: -10px; right: 16px;
  background: linear-gradient(100deg, var(--teal), var(--violet));
  color: #fff; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 12px; border-radius: 999px; text-transform: uppercase;
}
.plan-card .plan-head { display: flex; align-items: baseline; gap: 10px; }
.plan-card .plan-emoji { font-size: 1.5rem; }
.plan-card .plan-name { font-size: 1.1rem; font-weight: 800; }
.plan-card .plan-price { margin-left: auto; text-align: right; }
.plan-card .plan-price b { font-size: 1.35rem; }
.plan-card .plan-price span { display: block; font-size: 0.75rem; color: var(--text-dim); }
.plan-card p { margin-top: 8px; font-size: 0.88rem; color: var(--text-dim); line-height: 1.5; }

.sub-status { margin: 14px 0 2px; font-size: 0.9rem; }
.sub-status .badge { margin-right: 6px; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
}
.badge.premium { background: rgba(45, 212, 191, 0.15); color: var(--teal); border: 1px solid rgba(45, 212, 191, 0.4); }
.badge.trial { background: rgba(251, 191, 36, 0.12); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.35); }
.badge.expired { background: rgba(248, 113, 113, 0.12); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.35); }
.badge.locked { background: rgba(248, 113, 113, 0.2); color: #fecaca; border: 1px solid rgba(248, 113, 113, 0.5); }
.badge.admin { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.4); }
.badge.verified { background: rgba(52, 211, 153, 0.12); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.35); }
.badge.unverified { background: rgba(148, 163, 184, 0.12); color: var(--text-dim); border: 1px solid var(--stroke); }

/* --- Admin --- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-box {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 14px 16px;
}
.stat-box .num { font-size: 1.45rem; font-weight: 800; }
.stat-box .lbl { font-size: 0.74rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.stat-box.money .num { color: var(--teal); }

.admin-user {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 12px;
}
.admin-user .au-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-user .au-head b { font-size: 0.95rem; word-break: break-all; }
.admin-user .au-meta { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }
.admin-user .au-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn.mini {
  width: auto; margin: 0; padding: 8px 12px; font-size: 0.78rem; font-weight: 600;
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--stroke);
  border-radius: 10px; box-shadow: none;
}
.btn.mini.danger { color: #fecaca; border-color: rgba(248, 113, 113, 0.4); }
.btn.mini.good { color: var(--teal); border-color: rgba(45, 212, 191, 0.4); }

@media (min-width: 520px) {
  .view.active { padding-top: 36px; }
}
