/* MathComputers Support — branded remote support UI */
:root {
  --bg: #0b1220;
  --bg-elevated: #121a2b;
  --bg-card: #162033;
  --bg-soft: #1c2940;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #0b5cab;
  --primary-hover: #084a8a;
  --primary-soft: rgba(11, 92, 171, 0.15);
  --accent: #f59e0b;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(11, 92, 171, 0.28), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(245, 158, 11, 0.1), transparent);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

.container {
  width: min(1100px, 100% - 2rem);
  margin-inline: auto;
}

.container-narrow {
  width: min(480px, 100% - 2rem);
  margin-inline: auto;
}

/* Brand header */
.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  margin: 0.1rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.card-title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.card-sub {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Landing / client page */
.page-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0 3rem;
}

.hero-steps {
  display: grid;
  gap: 0.65rem;
  margin: 1.25rem 0 1.5rem;
}

.step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step strong {
  display: block;
  font-size: 0.95rem;
}

.step span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Forms */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field input.code-input {
  font-family: var(--mono);
  font-size: 1.75rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-weight: 700;
  padding: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
  text-decoration: none;
  color: white;
  background: var(--bg-soft);
}

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

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #1e40af);
  text-decoration: none;
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Status */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-pill.online .dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.status-pill.waiting .dot {
  background: var(--warning);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-pill.danger .dot {
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.alert-error {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.alert-success {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.alert-info {
  background: var(--primary-soft);
  border-color: rgba(59, 130, 246, 0.35);
  color: #bfdbfe;
}

.hidden {
  display: none !important;
}

/* Session live view (client) */
.live-layout {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 26, 43, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
}

.topbar-brand .brand-mark {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.live-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}

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

.video-stage {
  position: relative;
  background: #05080f;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
}

.video-stage video {
  max-width: 100%;
  max-height: calc(100vh - 70px);
  width: 100%;
  background: #000;
  object-fit: contain;
}

.video-stage.interactive video {
  cursor: crosshair;
}

.video-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.video-placeholder strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.side-panel {
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  max-height: calc(100vh - 70px);
}

@media (max-width: 900px) {
  .side-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }
}

.side-panel-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-bubble {
  max-width: 92%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem;
  word-break: break-word;
}

.chat-bubble.support {
  align-self: flex-start;
  background: var(--primary-soft);
  border: 1px solid rgba(11, 92, 171, 0.28);
}

.chat-bubble.client {
  align-self: flex-end;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.chat-bubble .who {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.chat-form input:focus {
  border-color: var(--primary);
}

/* Support dashboard */
.support-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}

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

.support-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.support-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.session-item {
  text-align: left;
  width: 100%;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.session-item:hover,
.session-item.active {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
}

.session-item .code {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 1.05rem;
}

.session-item .meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.code-display {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(59, 130, 246, 0.4);
  margin: 0.75rem 0;
}

.link-box {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.link-box input {
  flex: 1;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.footer-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 1.5rem;
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.control-bar .spacer {
  flex: 1;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.badge.ok {
  background: var(--success-soft);
  color: #86efac;
}

.badge.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.25rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Client waiting animation */
.waiting-box {
  text-align: center;
  padding: 2rem 1rem;
}

.waiting-box .spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.9s linear infinite;
}

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

/* Pointer overlay indicator for support */
.control-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0.9;
  max-width: 90%;
  text-align: center;
}

/* Helper panel (Windows full control) */
.helper-panel {
  margin: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--primary-soft);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.helper-panel strong {
  display: block;
  margin-bottom: 0.35rem;
}

.helper-panel p {
  margin: 0.35rem 0;
  color: var(--text-muted);
}

.helper-panel ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.helper-panel code,
.cmd-box code {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

.cmd-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.6rem 0;
}

.helper-sub {
  font-size: 0.78rem !important;
  word-break: break-all;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.live-stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.video-stage {
  flex: 1;
  min-height: 280px;
}

/* Klant: capture-video volledig buiten beeld (niet tonen) */
.local-preview-hidden,
#local-preview.local-preview-hidden,
.client-stage video#local-preview {
  position: fixed !important;
  left: -10000px !important;
  top: 0 !important;
  width: 320px !important;
  height: 180px !important;
  max-width: none !important;
  max-height: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
  visibility: hidden !important;
}

/* Geen video-element zichtbaar in de klant-stage */
.client-stage > video {
  display: none !important;
}
.client-stage > video.local-preview-hidden {
  display: block !important; /* nodig voor capture, maar off-screen */
  visibility: hidden !important;
}

.sharing-active {
  text-align: center;
  padding: 2.5rem 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}

.sharing-active strong {
  display: block;
  font-size: 1.25rem;
  color: #86efac;
  margin: 0.75rem 0 0.5rem;
}

.sharing-active p {
  margin: 0.4rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.sharing-active .sharing-tip {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 1rem;
}

.sharing-pulse {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--success-soft);
  border: 3px solid var(--success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  animation: share-pulse 1.6s ease-out infinite;
}

@keyframes share-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.client-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.remote-surface {
  max-width: 100%;
  max-height: calc(100vh - 70px);
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  touch-action: none;
}

canvas.remote-surface {
  image-rendering: auto;
  cursor: default;
}

canvas.remote-surface.interactive,
video.remote-surface.interactive {
  cursor: crosshair;
}

.support-stage {
  min-height: calc(100vh - 140px);
}

.active-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.active-panel.hidden {
  display: none !important;
}

.empty-main {
  min-height: auto;
  flex: 1;
}

.sidebar-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

/* Virtual keyboard (mobile support) */
.vkb {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  user-select: none;
}

.vkb-row {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  flex-wrap: wrap;
}

.vkb button {
  min-width: 2rem;
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  touch-action: manipulation;
}

.vkb button:active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.vkb button.vkb-wide {
  min-width: 8rem;
  flex: 1;
}

/* Mobile / Android layout */
@media (max-width: 900px) {
  .support-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .support-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem;
  }

  .session-list {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding-bottom: 0.25rem;
  }

  .session-item {
    min-width: 140px;
    flex-shrink: 0;
  }

  .control-bar {
    gap: 0.4rem;
  }

  .control-bar .badge {
    font-size: 0.7rem;
  }

  .support-stage {
    min-height: 45vh;
  }

  .live-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .side-panel {
    max-height: 32vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .code-input {
    font-size: 1.5rem !important;
    letter-spacing: 0.25em !important;
  }

  .brand-text h1 {
    font-size: 1.15rem;
  }

  .link-box {
    flex-direction: column;
  }

  .link-box input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card {
    padding: 1.25rem;
  }

  .btn {
    padding: 0.85rem 1rem;
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-form,
  .vkb,
  .control-bar {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

/* Primary CTA helpers */
.action-hint {
  margin: 0.45rem 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.action-hint.muted {
  color: var(--text-dim);
  margin-top: 0.4rem;
}

.launch-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.launch-overlay.hidden {
  display: none !important;
}

.launch-card {
  width: min(440px, 100%);
}

.launch-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
}

.launch-steps li {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}

.launch-steps strong {
  display: block;
  margin-bottom: 0.15rem;
}

.launch-steps span {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* File send panel (support) */
.file-send {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.file-send label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.file-send-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.file-send input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-progress {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
