/* SellerKavach Remote — matches app theme (AppColors + Inter). */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-soft: #DBEAFE;
  --secondary: #0EA5E9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --danger-soft: #FEE2E2;

  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --border: #E5E7EB;

  --screen-bg: #0B1120;
  --panel-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  --accent: var(--primary);
  --ok: var(--success);
  --warn: var(--warning);
  --err: var(--danger);
  --line: var(--border);
  --panel: var(--surface);

  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 0% -10%, rgba(37, 99, 235, 0.14), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(14, 165, 233, 0.10), transparent 55%),
    var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}
.brand, .meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
}
.meta { color: var(--muted); font-size: 0.9rem; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94A3B8;
  flex-shrink: 0;
}
.dot.idle { background: #94A3B8; }
.dot.pending { background: var(--warning); }
.dot.ok { background: var(--success); }
.dot.err { background: var(--danger); }

main {
  padding: 24px 20px;
  min-height: 0;
  display: flex;
  justify-content: center;
}

.panel {
  width: min(480px, 100%);
}
.auth-hero {
  text-align: center;
  margin-bottom: 18px;
}
.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.25);
  margin-bottom: 14px;
}
.auth-hero h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.lead {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--panel-shadow);
}
.device-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.86rem; margin-top: 14px; line-height: 1.45; }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.hidden { display: none !important; }
.footer-note {
  margin: 16px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

label {
  display: block;
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}
input[type="text"],
input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--primary-dark); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
button.ghost:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: #BFDBFE;
  color: var(--primary-dark);
}
button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  width: 100%;
  margin-top: 10px;
}
button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
}
#connectBtn { width: 100%; margin-top: 4px; }

.workspace {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  width: min(1280px, 100%);
  height: calc(100vh - 140px);
  min-height: 420px;
}
.workspace.panel-hidden {
  grid-template-columns: 1fr;
}
.workspace.theater-mode {
  width: 100%;
  height: calc(100vh - 52px);
  max-width: none;
  gap: 0;
}
body.theater .top,
body.theater .statusBar {
  display: none;
}
body.theater main {
  padding: 0;
  display: block;
}
body.theater .workspace {
  height: 100vh;
  border-radius: 0;
}
body.theater .screen-pane {
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.screen-pane, .side-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  min-height: 0;
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}
.screen-pane {
  display: grid;
  grid-template-rows: auto 1fr;
}
.view-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.view-toolbar-left,
.view-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
button.tool {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
}
button.tool:hover:not(:disabled) {
  background: #BFDBFE;
}
button.tool.primary {
  background: var(--primary);
  color: #fff;
}
button.tool.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}
button.tool.active {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
button.tool.danger-tool {
  background: var(--danger-soft);
  color: var(--danger);
}

.side-pane { padding: 16px; }
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.side-brand img {
  border-radius: 8px;
  object-fit: cover;
}
.side-brand strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
}
.side-brand span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
.side-pane h2 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.nav-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0 0 16px;
}
.nav-grid button {
  width: 100%;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.nav-grid button:hover:not(:disabled) {
  background: #BFDBFE;
}

.screen-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
/* Letterbox — fit inside, may show bars */
.screen-wrap.fit-contain #screenCanvas {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}
/*
 * Fill height — remove top/bottom bars, keep aspect ratio.
 * Width follows phone ratio (may crop left/right on wide screens).
 */
.screen-wrap.fit-cover {
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen-wrap.fit-cover #screenCanvas {
  position: relative;
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
}
.screen-wrap.rotated {
  transform: none;
}
.screen-wrap.rotated.fit-contain #screenCanvas {
  transform: rotate(90deg);
  max-width: 100vh;
  max-height: 100vw;
}
.screen-wrap.rotated.fit-cover #screenCanvas {
  transform: rotate(90deg);
  width: auto;
  height: 100%;
}
#screenCanvas {
  background: #000;
  pointer-events: none;
  image-rendering: auto;
}
.screen-wrap:fullscreen,
.screen-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen-wrap:fullscreen.fit-cover #screenCanvas,
.screen-wrap:-webkit-full-screen.fit-cover #screenCanvas {
  position: relative;
  inset: auto;
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
}
.screen-wrap:fullscreen.fit-contain #screenCanvas,
.screen-wrap:-webkit-full-screen.fit-contain #screenCanvas {
  position: relative;
  inset: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}
.screen-wrap:fullscreen .fs-hud,
.screen-wrap:-webkit-full-screen .fs-hud {
  display: flex !important;
}
.fs-hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.screen-wrap:fullscreen:hover .fs-hud,
.screen-wrap:-webkit-full-screen:hover .fs-hud,
.fs-hud.visible {
  opacity: 1;
}
.fs-hud-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  color: #fff;
  font-weight: 700;
}
.fs-hud-bar img {
  border-radius: 6px;
  object-fit: cover;
}
.fs-hint {
  margin: 0;
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  pointer-events: none;
}
.input-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.touch-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.95);
  background: rgba(37, 99, 235, 0.25);
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.2s ease;
}
.screen-placeholder {
  position: absolute;
  color: #94A3B8;
  pointer-events: none;
  z-index: 1;
  font-weight: 500;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.toggle input { width: auto; margin: 0; accent-color: var(--primary); }
.kbd-label { margin-top: 12px; }
.key-capture {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.statusBar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.94);
}
.status-brand {
  font-weight: 700;
  color: var(--primary);
  margin-right: 8px;
}

.sync-card {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 70%);
}
.sync-card h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}
.sync-lead {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.sync-path {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  word-break: break-word;
}
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.primary-btn {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}
.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.sync-status {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}
.sync-hint {
  margin: 8px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.sync-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.sync-modal.hidden { display: none !important; }
.sync-modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  padding: 22px 20px 18px;
  text-align: center;
}
.sync-modal-card img {
  border-radius: 12px;
  margin-bottom: 10px;
}
.sync-modal-step {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.sync-modal-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}
.sync-modal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.sync-modal-path {
  margin-top: 10px !important;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  color: var(--text) !important;
  font-weight: 600;
  word-break: break-word;
}
.sync-modal-path:empty { display: none; }
.sync-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.sync-modal-actions .primary-btn,
.sync-modal-actions .ghost {
  width: 100%;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .workspace.panel-hidden {
    grid-template-columns: 1fr;
  }
  .screen-wrap { min-height: 55vh; }
  .top { padding: 10px 14px; }
  main { padding: 16px 14px; }
  .view-toolbar { padding: 8px; }
}
