/* AdvysorTV — Player (TV-side). Dark theme, shares brand DNA with the admin app. */

:root {
  /* Brand */
  --pink: #F45B8D;
  --pink-light: #FF5C8A;
  --purple: #5B2CBF;
  --purple-light: #8B6BE8;
  --gradient: linear-gradient(135deg, #F45B8D 0%, #5B2CBF 100%);
  --gradient-vivid: linear-gradient(135deg, #FF5C8A 0%, #6B33D6 100%);

  /* Dark surfaces (purple-tinted near-black) */
  --bg: #0E0A16;
  --bg-2: #15101F;
  --surface: #1C1530;
  --surface-2: #241B3A;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  --text: #F4F1FA;
  --text-muted: #B3A9C6;
  --text-faint: #756B88;

  --success: #34D399;
  --success-bg: rgba(52,211,153,0.14);
  --warning: #F5C04A;
  --warning-bg: rgba(245,192,74,0.14);
  --danger: #FB7185;
  --danger-bg: rgba(251,113,133,0.14);

  --shadow-pop: 0 12px 40px rgba(244,91,141,0.30), 0 4px 16px rgba(91,44,191,0.24);
  --shadow-lg: 0 24px 80px rgba(0,0,0,0.55);

  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  cursor: default;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }

/* ============ Atmospheric aurora backdrop ============ */
.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.aurora::before, .aurora::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.55;
}
.aurora::before {
  width: 60vw; height: 60vw; left: -12vw; top: -18vw;
  background: radial-gradient(circle, rgba(244,91,141,0.55), transparent 68%);
  animation: drift1 22s ease-in-out infinite alternate;
}
.aurora::after {
  width: 64vw; height: 64vw; right: -16vw; bottom: -22vw;
  background: radial-gradient(circle, rgba(91,44,191,0.6), transparent 68%);
  animation: drift2 26s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(8vw, 6vh) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-7vw, -5vh) scale(1.15); } }

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ Brand mark ============ */
.brand-logo { height: 80px; width: auto; display: block; object-fit: contain; }
.brand-logo.sm { height: 40px; }

/* ============================================================
   PAIRING SCREEN
   ============================================================ */
.pair {
  position: relative; z-index: 2;
  height: 100vh; width: 100vw;
  display: flex; flex-direction: column;
  padding: clamp(28px, 4vh, 56px) clamp(36px, 5vw, 80px);
}
.pair-top { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.pair-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 99px; font-size: 13px; color: var(--text-muted);
  font-weight: 500; backdrop-filter: blur(8px);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}
.dot-waiting { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-bg); }
.dot-connecting { background: var(--text-faint); box-shadow: 0 0 0 4px rgba(117,107,136,0.2); }

.pair-body {
  flex: 1; display: grid; align-items: center; gap: clamp(40px, 6vw, 96px);
}
.pair-body.layout-split { grid-template-columns: auto auto; justify-content: center; }
.pair-body.layout-stack { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.pair-body.layout-card  { grid-template-columns: 1fr 1fr; }

/* QR block */
.qr-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.qr-card {
  background: #fff; border-radius: 28px; padding: clamp(22px, 2.4vw, 34px);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  position: relative;
}
.qr-card::after {
  content: ''; position: absolute; inset: -2px; border-radius: 30px; z-index: -1;
  background: var(--gradient); opacity: 0.9; filter: blur(14px);
}
.qr-svg { display: block; width: clamp(220px, 22vw, 340px); height: clamp(220px, 22vw, 340px); }
.qr-hint {
  display: flex; align-items: center; gap: 9px;
  color: var(--text-muted); font-size: 15px; font-weight: 500;
}

/* Code block */
.code-block { max-width: 560px; }
.code-eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--pink-light); margin-bottom: 14px;
}
.code-block h1 {
  font-size: clamp(34px, 4vw, 56px); font-weight: 600; line-height: 1.05;
  letter-spacing: -0.02em; margin: 0 0 18px; max-width: 14ch;
}
.code-block .lede {
  font-size: clamp(16px, 1.4vw, 20px); color: var(--text-muted);
  margin: 0 0 36px; line-height: 1.5; max-width: 520px;
}

.pin-display { display: flex; gap: clamp(12px, 1.2vw, 18px); margin-bottom: 30px; }
.pin-digit {
  width: clamp(76px, 8vw, 116px); height: clamp(96px, 11vw, 150px);
  border-radius: 22px; background: var(--surface);
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: clamp(48px, 6vw, 84px); font-weight: 600; letter-spacing: -0.02em;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 16px 40px rgba(0,0,0,0.35);
  position: relative; overflow: hidden;
}
.pin-digit::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: var(--gradient); opacity: 0.85;
}
.pin-digit.flip { animation: flip 0.5s cubic-bezier(0.4,0,0.2,1); }
@keyframes flip {
  0% { transform: rotateX(0); }
  45% { transform: rotateX(90deg); opacity: 0.3; }
  55% { transform: rotateX(-90deg); opacity: 0.3; }
  100% { transform: rotateX(0); opacity: 1; }
}

.pair-actions { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.code-meta { display: flex; align-items: center; gap: 14px; margin-top: 26px; color: var(--text-faint); font-size: 14px; }
.code-meta .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--text-faint); }

.pair-error {
  background: var(--danger-bg); border: 1px solid rgba(251,113,133,0.25);
  color: var(--danger); padding: 12px 16px; border-radius: 12px;
  font-size: 14px; margin-bottom: 20px;
}

/* ============ Language toggle ============ */
.lang-toggle {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 99px; overflow: hidden;
}
.lang-toggle .opt {
  padding: 5px 11px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--text-faint); cursor: pointer; border: none; background: none;
  transition: all 0.15s ease; font-family: inherit;
}
.lang-toggle .opt.active {
  background: var(--gradient); color: #fff; cursor: default;
}
.lang-toggle .opt:not(.active):hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 24px; border-radius: 14px; font-weight: 600; font-size: 15px;
  border: 1px solid transparent; transition: all 0.16s ease; white-space: nowrap;
}
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-pop); }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: rgba(255,255,255,0.05); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: var(--border-strong); }
.btn-quiet { color: var(--text-muted); }
.btn-quiet:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-lg { padding: 16px 30px; font-size: 16px; border-radius: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================================
   CONTENT PLAYER
   ============================================================ */
.player { position: relative; height: 100vh; width: 100vw; background: #000; overflow: hidden; }

.stage { position: absolute; inset: 0; }
.slide {
  position: absolute; inset: 0;
  display: grid; place-items: center; overflow: hidden;
}

/* No-content state */
.no-content {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; color: var(--text-muted); font-size: 16px; text-align: center; padding: 40px;
}

/* Content canvases */
.canvas { position: absolute; inset: 0; display: grid; }

/* image */
.c-image { background: #000; }

/* video */
.c-video { background: #000; }
.c-video .vbar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(255,255,255,0.12); z-index: 1; }
.c-video .vbar > i { display: block; height: 100%; background: var(--gradient-vivid); width: 0; }
.c-video .vbar > i.anim { animation: fillbar linear forwards; }

/* text canvas */
.c-text {
  place-items: center; padding: clamp(50px,8vh,120px); text-align: center;
  background: radial-gradient(ellipse at 20% 80%, rgba(91,44,191,0.4) 0%, transparent 55%),
              radial-gradient(ellipse at 80% 20%, rgba(244,91,141,0.22) 0%, transparent 55%),
              #0E0A16;
}
.c-text .tinner { max-width: min(92vw, 1100px); position: relative; z-index: 1; }
.c-text h2 { font-size: clamp(42px,6vw,104px); font-weight: 700; line-height: 1.04; letter-spacing: -0.03em; margin: 0; }
.c-text .tdesc { font-size: clamp(30px,4vw,40px); color: var(--text-muted); margin: 28px 0 0; line-height: 1.55; font-weight: 400; white-space: pre-wrap;}

/* progress dots */
.progress-row {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; gap: 6px; padding: 16px clamp(24px,3vw,48px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.progress-row .seg { flex: 1; height: 4px; border-radius: 99px; background: rgba(255,255,255,0.18); overflow: hidden; }
.progress-row .seg > i { display: block; height: 100%; background: #fff; width: 0; border-radius: 99px; }
.progress-row .seg > i.anim { animation: fillbar linear forwards; }
.progress-row .seg.done > i { width: 100%; }
@keyframes fillbar { from { width: 0; } to { width: 100%; } }

/* Chrome auto-hide */
.chrome { transition: opacity 0.45s ease, transform 0.45s ease; }
.chrome.hidden { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.player.idle { cursor: none; }

/* Controls */
.controls {
  position: absolute; top: clamp(20px,3vh,38px); left: 50%; transform: translateX(-50%);
  z-index: 40; display: flex; align-items: center; gap: 8px;
  background: rgba(20,14,30,0.72); backdrop-filter: blur(18px);
  border: 1px solid var(--border-strong); border-radius: 18px; padding: 10px;
  box-shadow: var(--shadow-lg);
}
.ctrl {
  width: 52px; height: 52px; border-radius: 13px; display: grid; place-items: center;
  color: var(--text-muted); transition: all 0.14s ease;
}
.ctrl:hover { background: rgba(255,255,255,0.1); color: #fff; }
.ctrl:active { transform: scale(0.94); }
.ctrl.wide { display: flex; flex-direction: row; align-items: center; width: auto; padding: 0 18px; gap: 9px; font-weight: 600; font-size: 14px; }
.ctrl.danger:hover { background: var(--danger-bg); color: var(--danger); }
.ctrl.primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-pop); }
.ctrl-sep { width: 1px; height: 30px; background: var(--border); margin: 0 4px; }
.ctrl .lbl { font-size: 14px; font-weight: 600; }

/* Footer (docked — controls live here) */
.footer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 35;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(12px,3vw,48px) 16px;
  background: rgba(16,11,24,0.86); backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-strong);
  gap: 20px; overflow: hidden;
}
.footer.chrome.hidden { transform: translateY(12px); }
.footer-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex-shrink: 0; }
.footer-left .device-name { font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; align-self: center; line-height: 1; display: flex; align-items: center; }
.footer-right { display: flex; align-items: center; gap: clamp(6px,1.2vw,26px); min-width: 0; flex-shrink: 1; overflow: hidden; }
.f-stat { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.f-stat .ico { display: grid; place-items: center; }
.f-stat.online .ico { color: var(--success); }
.f-stat.offline .ico { color: var(--danger); }
.f-stat.offline { color: var(--danger); }

.dl { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.dl-ring { position: relative; width: 26px; height: 26px; }
.dl-ring svg { transform: rotate(-90deg); display: block; }
.dl-ring .trk { stroke: rgba(255,255,255,0.14); }
.dl-ring .bar { stroke: url(#dlgrad); stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }
.dl.done { color: var(--success); }
.dl.syncing { color: var(--text); }
.dl .pct { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.clock {
  display: flex; align-items: baseline; gap: 8px;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.clock .time { font-size: clamp(18px,1.8vw,26px); letter-spacing: 0.01em; }
.clock .sec { font-size: 14px; color: var(--text-faint); font-weight: 500; }
.clock .ampm { font-size: 13px; color: var(--text-faint); font-weight: 600; }
.f-sep { width: 1px; height: 26px; background: var(--border); }

/* Offline banner */
.offline-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 45;
  background: var(--danger-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(251,113,133,0.3);
  color: #FECDD3; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px; font-size: 14px; font-weight: 600;
  transform: translateY(-100%); transition: transform 0.4s ease;
}
.offline-banner.show { transform: translateY(0); }

.reassign-banner {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(14,10,22,0.92); backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  color: #E2D9F3; text-align: center;
  animation: fadein 0.4s ease;
}
.reassign-text { display: flex; flex-direction: column; gap: 8px; }
.reassign-text span { font-size: 20px; font-weight: 600; }
.reassign-text .reassign-sub { font-size: 15px; font-weight: 400; color: var(--text-muted); }

/* Logout confirm */
.confirm-backdrop {
  position: fixed; inset: 0; z-index: 150; background: rgba(6,4,12,0.7); backdrop-filter: blur(8px);
  display: grid; place-items: center; animation: fade 0.2s ease; padding: 24px;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.confirm {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 24px;
  padding: 34px; max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
  animation: pop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: none; } }
.confirm .warn-ico {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px;
  background: var(--danger-bg); color: var(--danger); display: grid; place-items: center;
}
.confirm .welcome-ico {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px;
  background: var(--gradient); color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
}
.confirm .device-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-strong);
  padding: 7px 16px; border-radius: 99px; font-size: 14px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 18px;
}
.confirm h3 { margin: 0 0 8px; font-size: 22px; font-weight: 600; color: var(--text); }
.confirm p { margin: 0 0 26px; color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.confirm .row { display: flex; gap: 12px; flex-wrap: wrap; }
.confirm .row .btn { flex: 1; justify-content: center; min-width: fit-content; }

/* Animations */
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Blazor error UI */
#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  background: var(--danger-bg); color: var(--text); padding: 12px 16px;
  font-size: 14px; text-align: center;
}
#blazor-error-ui .reload { color: var(--pink-light); margin-left: 8px; cursor: pointer; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
