/*
  Theme system
  - Default: light
  - Dark: html[data-theme="dark"]
*/
:root{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#ffffff;
  --text:#0f172a;
  --muted:rgba(15,23,42,.72);
  --line:rgba(15,23,42,.10);
  --brand:#2563eb;
  --brand-soft:rgba(37,99,235,.14);
  --ok:#0ea5a5;
  --bad:#e11d48;
  --radius:18px;
  --shadow:0 18px 50px rgba(2,6,23,.12);
}

html[data-theme="dark"]{
  --bg:#070b16;
  --panel:rgba(12,20,42,.86);
  --panel2:#0a1022;
  --text:#eaf0ff;
  --muted:rgba(234,240,255,.78);
  --line:rgba(255,255,255,.10);
  --brand:#2e6bff;
  --brand-soft:rgba(46,107,255,.16);
  --ok:#2bd9a7;
  --bad:#ff4d6d;
  --shadow:0 18px 50px rgba(0,0,0,.40);
}

*{
  box-sizing:border-box;
}

html,body{
  height:100%;
}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:
    radial-gradient(1200px 520px at 16% -10%, var(--brand-soft), transparent 62%),
    radial-gradient(900px 520px at 92% 6%, rgba(14,165,233,.12), transparent 58%),
    var(--bg);
  color:var(--text);
}

/* =========================================================
   Full-screen login overlay (spinner + blur)
   Used for passkey/QR approval and 2FA submit.
   ========================================================= */

.login-overlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.login-overlay.is-show{
  display:flex;
}

.login-overlay::before{
  content:"";
  position:absolute;
  inset:0;
  background:rgba(2,6,23,.35);
}

html[data-theme="light"] .login-overlay::before{
  background:rgba(15,23,42,.28);
}

.login-overlay-card{
  position:relative;
  width:min(520px, calc(100% - 44px));
  border:1px solid var(--line);
  border-radius:calc(var(--radius) + 6px);
  background:var(--panel);
  box-shadow:var(--shadow);
  padding:22px 22px;
  display:flex;
  gap:14px;
  align-items:center;
  backdrop-filter: blur(14px);
}

.login-overlay-spin{
  width:28px;
  height:28px;
  border-radius:50%;
  border:3px solid rgba(255,255,255,.25);
  border-top-color: var(--brand);
  animation: loginSpin 0.9s linear infinite;
}

html[data-theme="light"] .login-overlay-spin{
  border:3px solid rgba(15,23,42,.18);
  border-top-color: var(--brand);
}

@keyframes loginSpin{
  to{ transform: rotate(360deg); }
}

.login-overlay-title{
  font-weight:900;
  letter-spacing:-.2px;
}

.login-overlay-sub{
  margin-top:2px;
  color:var(--muted);
  font-size:13px;
}

/* Blur the page underneath when overlay is visible */
body.overlay-on .auth-shell,
body.overlay-on .container{
  filter: blur(7px);
  transition: filter .16s ease;
}

body.overlay-on{
  overflow:hidden;
}

a{
  color:var(--brand);
  text-decoration:none;
}
a:hover{
  text-decoration:underline;
}

.container{
  max-width:1100px;
  margin:0 auto;
  padding:30px;
}

/* Modern split auth layout */
.auth-shell{
  min-height:100dvh;
  display:grid;
  grid-template-columns:1.15fr 1fr;
}

.auth-side{
  position:relative;
  padding:52px 54px;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  border-right:1px solid rgba(255,255,255,.08);
  background:
    linear-gradient(180deg, rgba(5,10,25,.54), rgba(5,10,25,.76)),
    url('./login-bg.webp') center center / cover no-repeat,
    var(--bg);
  overflow:hidden;
}

.auth-side::before{
  content:"";
  position:absolute;
  inset:0;
  background:radial-gradient(circle at 42% 38%, rgba(66,145,255,.16), transparent 26%);
  pointer-events:none;
}

/* Make the left panel use the full viewport height cleanly and let the ring scale up */
.side-content{
  position:relative;
  z-index:1;
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  min-height:0;
  gap:0;
  padding-top:52px;
}

.side-content--login{
  max-width:640px;
}

.auth-side > .brand{
  position:relative;
  z-index:2;
  display:inline-flex;
  align-items:center;
  width:max-content;
  padding:10px 14px;
  border-radius:18px;
  background:linear-gradient(180deg, rgba(8,16,38,.38), rgba(8,16,38,.18));
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 18px 40px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(6px);
}

.auth-side > .brand .brand-logo{
  height:56px;
  max-width:320px;
  filter: drop-shadow(0 16px 30px rgba(0,0,0,.34)) drop-shadow(0 0 24px rgba(92,155,255,.26));
}

.auth-card .brand-logo--small{
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.25)) drop-shadow(0 0 16px rgba(92,155,255,.18));
}

.auth-main{
  display:flex;
  flex-direction:column;
  justify-content:center;
  padding:36px 44px;
  align-items:center;
  gap:16px;
  background:linear-gradient(180deg, rgba(5,10,25,.12), rgba(5,10,25,.3));
}

.auth-card{
  width:min(510px, 100%);
  border:1px solid rgba(255,255,255,.08);
  border-radius:28px;
  background:linear-gradient(180deg, rgba(9,17,38,.90), rgba(7,14,32,.94));
  backdrop-filter: blur(14px);
  box-shadow:0 26px 80px rgba(0,0,0,.42);
  padding:30px 30px 26px;
}

.auth-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}

.auth-title{
  font-size:24px;
  font-weight:900;
  letter-spacing:-.4px;
}

.auth-sub{
  margin-top:4px;
  color:var(--muted);
  font-size:14px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.mark{
  width:44px;
  height:44px;
  border-radius:14px;
  display:grid;
  place-items:center;
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow:var(--shadow);
  font-weight:900;
}

.brand-logo{
  display:block;
  height:44px;
  width:auto;
  max-width:260px;
  object-fit:contain;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.28)) drop-shadow(0 0 18px rgba(77,146,255,.18));
}

.brand-logo--small{
  height:26px;
  max-width:180px;
  filter:none;
}

.brand-name{
  font-weight:900;
  letter-spacing:.2px;
}

.brand-tag{
  color:var(--muted);
  font-size:14px;
  margin-top:2px;
}

.side-content h1{
  margin:0 0 14px;
  font-size:58px;
  font-weight:900;
  line-height:0.98;
  letter-spacing:-1.6px;
  color:#f4f7ff;
  text-shadow:0 10px 32px rgba(0,0,0,.28);
}

.side-content p{
  margin:0 0 18px;
  color:rgba(231,239,255,.92);
  max-width:26ch;
  font-size:16px;
  line-height:1.55;
  text-shadow:0 6px 20px rgba(0,0,0,.22);
}

.side-points,
.side-footer{ display:none; }

.auth-hint{
  color:var(--muted);
  font-size:13px;
  text-align:center;
}

.theme-toggle{
  width:42px;
  height:42px;
  border-radius:999px;
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  display:grid;
  place-items:center;
  transition: transform .08s ease, filter .2s ease;
}

.theme-toggle:hover{ filter:brightness(1.05); }
.theme-toggle:active{ transform:translateY(1px); }

@media (max-width: 980px){
  .auth-shell{ grid-template-columns: 1fr; }
  .auth-side{ display:none; }
  .auth-main{ padding:24px; }
}

@media (min-width: 981px){
  .auth-side{ min-height:100dvh; }
}

.brandbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 20px;
  border:1px solid var(--line);
  border-radius:999px;
  background:color-mix(in srgb, var(--panel), transparent 12%);
  backdrop-filter: blur(10px);
}

.logo{
  display:flex;
  align-items:center;
  gap:12px;
  font-weight:800;
  letter-spacing:.2px;
  font-size:18px;
}

.dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:var(--brand);
  box-shadow:0 0 0 6px var(--brand-soft);
}

.badge{
  font-size:12px;
  padding:6px 12px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  background:color-mix(in srgb, var(--panel2), transparent 8%);
}

.grid{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:20px;
  margin-top:20px;
}

@media (max-width:900px){
  .grid{
    grid-template-columns:1fr;
  }
}

.card{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--panel);
  backdrop-filter: blur(14px);
  box-shadow:var(--shadow);
  padding:24px;
}

.card h2{
  margin:0 0 10px;
  font-size:18px;
}

.muted{
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
}

.sep{
  height:1px;
  background:var(--line);
  margin:18px 0;
}

label{
  display:block;
  font-size:13px;
  margin:12px 0 6px;
  color:var(--muted);
}

.input{
  width:100%;
  padding:14px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--panel2);
  color:var(--text);
  outline:none;
  transition:.2s ease;
}

.input:focus{
  border-color:rgba(46,107,255,.6);
  box-shadow:0 0 0 6px rgba(46,107,255,.15);
}

.btn{
  width:100%;
  padding:15px 16px;
  border-radius:16px;
  border:0;
  background:linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand), #000 8%));
  color:white;
  font-weight:800;
  cursor:pointer;
  transition: transform .08s ease, filter .2s ease;
}

.btn:hover{
  filter:brightness(1.05);
}

.btn:active{
  transform:translateY(1px);
}

.alert{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--muted);
  font-size:13px;
}

.alert.bad{
  border-color:rgba(255,77,109,.30);
  background:rgba(255,77,109,.12);
  color:#ffd6de;
}

.alert.ok{
  border-color:rgba(43,217,167,.25);
  background:rgba(43,217,167,.10);
  color:#d7fff3;
}

/* QR SECTION */

.qrWrap{
  display:flex;
  gap:18px;
  align-items:center;
  flex-wrap:wrap;
}

.qrBox{
  width:240px;
  height:240px;
  border-radius:20px;
  background:#ffffff;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  padding:12px;
  box-shadow:0 0 0 1px rgba(0,0,0,.15);
}

.qrBox img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  image-rendering:-webkit-optimize-contrast;
  image-rendering:crisp-edges;
}

/* Status Pills */

.pill{
  display:inline-flex;
  gap:8px;
  align-items:center;
  font-size:13px;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--muted);
}

.spin{
  width:12px;
  height:12px;
  border-radius:999px;
  border:2px solid rgba(255,255,255,.25);
  border-top-color:#ffffff;
  animation:spin 1s linear infinite;
}

@keyframes spin{
  to{ transform:rotate(360deg); }
}

.footer{
  margin-top:16px;
  color:var(--muted);
  font-size:12px;
}

/* ---- Login ring + theme-safe logos ---- */
.brand-logo--dark{ display:block; }
.brand-logo--light{ display:none; }
html[data-theme="light"] .brand-logo--dark{ display:none; }
html[data-theme="light"] .brand-logo--light{ display:block; }

/* Auth module strip (replaces old wheel artwork) */
.module-strip{
  margin-top:22px;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  max-width:520px;
}
.module-strip__item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background:linear-gradient(180deg, rgba(8,16,38,.48), rgba(8,16,38,.22));
  box-shadow:0 14px 34px rgba(0,0,0,.18);
  color:#f4f8ff;
  font-weight:800;
}
.module-strip__dot{
  width:12px;
  height:12px;
  border-radius:50%;
  background:linear-gradient(180deg, #4d93ff, #2e6bff);
  box-shadow:0 0 0 5px rgba(77,147,255,.16);
  flex:0 0 12px;
}
html[data-theme="light"] .module-strip__item{
  color:#0f172a;
  border-color:rgba(15,23,42,.10);
  background:linear-gradient(180deg, rgba(255,255,255,.86), rgba(244,247,255,.92));
  box-shadow:0 18px 42px rgba(15,23,42,.10);
}
html[data-theme="light"] .module-strip__dot{
  box-shadow:0 0 0 5px rgba(37,99,235,.10);
}

/* Feature ring sizing + theme */
.feature-ring{
  margin-top: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex: 1;
  min-height: 0;
}
.feature-ring img{
  /* Bigger, more “hero” presence on desktop while still fitting the viewport */
  width: clamp(460px, 52vw, 760px);
  max-width: 100%;
  height: auto;
  /* Prevent the ring from pushing the bullets/footer off-screen */
  max-height: min(760px, 72dvh, calc(100dvh - 360px));
  filter: drop-shadow(0 28px 70px rgba(0,0,0,.35));
}

/* make SVG labels readable on light theme */
html[data-theme="light"] .feature-ring img{
  /* Keep the ring readable in light theme while preserving depth */
  filter: invert(1) hue-rotate(180deg) drop-shadow(0 28px 70px rgba(0,0,0,.18));
  opacity: .92;
}

/* When the screen is shorter, keep the ring from squeezing other content */
@media (max-height: 760px){
  .feature-ring{ flex: 0; }
  .feature-ring img{ width: clamp(360px, 46vw, 620px); max-height: min(56vh, 620px); }
}

@media (max-width: 900px){
  .module-strip{grid-template-columns:1fr;}
}


/* --- Admin UI enhancements (links, badges, banners) --- */
.role-badge{
  display:inline-flex;align-items:center;justify-content:center;
  padding:4px 10px;border-radius:999px;font-weight:700;font-size:12px;
  border:1px solid rgba(255,255,255,.14);
}
.role-badge--admin{ background: rgba(34,197,94,.16); color:#22C55E; }
.role-badge--user{  background: rgba(59,130,246,.14); color:#60A5FA; }

.panel-btn, .btn{
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}
.panel-btn:hover, .btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}
.panel-btn--ghost, .btn--ghost{
  background: rgba(255,255,255,.06) !important;
  border: 1px solid rgba(255,255,255,.14) !important;
}
.panel-btn--ghost:hover, .btn--ghost:hover{
  background: rgba(255,255,255,.10) !important;
  border-color: rgba(255,255,255,.22) !important;
}

.dash-banner{
  font-weight:700;
  border-width:1px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}


/* Admin Users enhancements */
.role-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  font-weight:800;
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--panel2), transparent 10%);
  color: var(--muted);
}
.role-badge--admin{
  color: var(--text);
  border-color: color-mix(in srgb, var(--brand), var(--line) 55%);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.role-badge--user{
  opacity:.9;
}

.panel-btn{
  border-radius:12px;
}
.panel-btn--primary{
  border:1px solid color-mix(in srgb, var(--brand), var(--line) 55%);
  background: color-mix(in srgb, var(--brand), transparent 78%);
  color: var(--text);
}
.panel-btn--primary:hover{
  background: color-mix(in srgb, var(--brand), transparent 72%);
  border-color: color-mix(in srgb, var(--brand), var(--line) 35%);
}

.panel-btn--danger{
  border:1px solid rgba(239,68,68,.45);
  background: rgba(239,68,68,.14);
  color: var(--text);
}
.panel-btn--danger:hover{
  background: rgba(239,68,68,.20);
  border-color: rgba(239,68,68,.65);
}

.dash-banner{
  padding:12px 14px;
  border-radius:14px;
  margin-bottom:14px;
  display:flex;
  align-items:center;
  gap:10px;
}
.dash-banner--ok{
  border:1px solid color-mix(in srgb, var(--brand), var(--line) 55%);
  background: color-mix(in srgb, var(--brand), transparent 86%);
}
.dash-banner--bad{
  border:1px solid rgba(239,68,68,.50);
  background: rgba(239,68,68,.12);
}


/* Light theme fixes for login after background refresh */
html[data-theme="light"] .auth-side{
  border-right:1px solid rgba(15,23,42,.08);
  background:
    linear-gradient(180deg, rgba(249,252,255,.90), rgba(238,244,253,.96)),
    radial-gradient(circle at 18% 34%, rgba(59,130,246,.22), transparent 22%),
    radial-gradient(circle at 78% 22%, rgba(96,165,250,.16), transparent 24%),
    url('./login-bg.webp') center center / cover no-repeat;
  background-blend-mode: normal, screen, screen, normal;
}
html[data-theme="light"] .auth-side::before{
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.02)),
    radial-gradient(circle at 42% 38%, rgba(66,145,255,.10), transparent 30%);
}
html[data-theme="light"] .side-content h1{
  color:#0f172a;
  text-shadow:0 10px 26px rgba(255,255,255,.55);
}
html[data-theme="light"] .side-content p{
  color:rgba(15,23,42,.82);
  text-shadow:0 6px 18px rgba(255,255,255,.45);
}
html[data-theme="light"] .auth-main{
  background:
    radial-gradient(820px 420px at 100% 0%, rgba(37,99,235,.08), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.84), rgba(244,247,253,.98));
}
html[data-theme="light"] .auth-card{
  border:1px solid rgba(15,23,42,.10);
  background:linear-gradient(180deg, rgba(255,255,255,.97), rgba(247,250,255,.99));
  box-shadow:0 24px 64px rgba(15,23,42,.10);
}
html[data-theme="light"] .auth-title,
html[data-theme="light"] h2,
html[data-theme="light"] .footer{
  color:var(--text);
}
html[data-theme="light"] .muted,
html[data-theme="light"] .auth-sub,
html[data-theme="light"] label,
html[data-theme="light"] .auth-hint{
  color:var(--muted);
}
html[data-theme="light"] .theme-toggle{
  background:rgba(255,255,255,.82);
}
html[data-theme="light"] .pill{
  background:rgba(255,255,255,.82);
  box-shadow:0 8px 18px rgba(15,23,42,.06);
}
html[data-theme="light"] .auth-side > .brand{
  background:linear-gradient(180deg, rgba(255,255,255,.66), rgba(255,255,255,.42));
  border-color:rgba(15,23,42,.08);
  box-shadow:0 14px 34px rgba(15,23,42,.08), inset 0 1px 0 rgba(255,255,255,.65);
}
html[data-theme="light"] .auth-side > .brand .brand-logo{
  filter:drop-shadow(0 12px 24px rgba(15,23,42,.12)) drop-shadow(0 0 12px rgba(92,155,255,.12));
}
