/*
 * WhaMesh — cockpit e login (/app, /entrar)
 * Mesmos tokens e linguagem visual da home (Modelo-2/src/styles.css).
 * Mantém os nomes de classe que cockpit.js e entrar.js já usam; as variáveis
 * antigas (--text-main, --accent-primary…) ficam como alias dos tokens novos.
 */
:root {
  --radius: 8px;
  --background: oklch(0.13 0.006 130);
  --foreground: oklch(0.95 0.01 120);
  --card: oklch(0.165 0.007 130);
  --muted: oklch(0.2 0.008 130);
  --muted-foreground: oklch(0.62 0.015 125);
  --primary: oklch(0.75 0.2 150);
  --primary-foreground: oklch(0.15 0.02 130);
  --destructive: oklch(0.65 0.2 25);
  --warn: oklch(0.8 0.15 85);
  --border: oklch(1 0 0 / 8%);
  --input: oklch(1 0 0 / 12%);
  --font-sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* alias das variáveis usadas por cockpit.js / entrar.js */
  --text-main: var(--foreground);
  --text-muted: var(--muted-foreground);
  --text-dim: var(--muted-foreground);
  --accent-primary: var(--primary);
  --color-danger: var(--destructive);
  --bg-base: var(--background);
  --border-hairline: var(--border);
}

* { box-sizing: border-box; border-color: var(--border); }
html { color-scheme: dark; }
body {
  margin: 0; min-height: 100vh;
  background: var(--background); color: var(--foreground);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--primary); color: var(--primary-foreground); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); }
[hidden] { display: none !important; }
.font-heading { font-family: var(--font-sans); }

/* fundo em grade, como a home */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, oklch(1 0 0 / 3%) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(1 0 0 / 3%) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, black 20%, transparent 80%);
}

/* ── topo ─────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px; padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 72%, transparent);
  backdrop-filter: blur(20px);
}
.app-header-left, .app-header-right { display: flex; align-items: center; gap: 14px; }
.app-logo, .entrar-logo { display: flex; align-items: center; gap: 10px; color: var(--foreground); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.app-logo:hover, .entrar-logo:hover { text-decoration: none; }
.live-beacon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; background: var(--primary); flex: none; }
.live-beacon::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--primary-foreground); }
.app-badge {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; color: var(--primary);
}

/* ── botões ───────────────────────────────────────────────────────────── */
.btn, .btn-primary-island {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: opacity .15s, background .15s;
}
.btn:hover, .btn-primary-island:hover { text-decoration: none; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-primary-island { background: var(--foreground); color: var(--background); }
.btn-primary-island:hover:not(:disabled) { opacity: .9; }
.btn-secondary { background: transparent; color: var(--foreground); border-color: var(--input); }
.btn-secondary:hover:not(:disabled) { background: var(--muted); }
.btn:disabled, .btn-primary-island:disabled { opacity: .5; cursor: default; }
.btn-icon-pill { display: grid; place-items: center; }

/* ── cartões e formulários ────────────────────────────────────────────── */
.glass-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in oklab, var(--background) 60%, black);
}
.input-clean, input[type=text], input[type=email], input[type=password] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--input); border-radius: 6px;
  background: transparent; color: var(--foreground); font: inherit; outline: none;
}
.input-clean:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 20%, transparent); }
input::placeholder { color: color-mix(in oklab, var(--muted-foreground) 70%, transparent); }
input[type=checkbox] { width: auto; height: auto; accent-color: var(--primary); }

/* ── cockpit: grade ───────────────────────────────────────────────────── */
.operator-workspace-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; padding: 24px; }
.cockpit-sidebar { display: flex; flex-direction: column; gap: 14px; align-self: start; position: sticky; top: 88px; }
.cockpit-main-canvas { min-width: 0; }

.cockpit-beacon-box { padding: 16px; }
.cockpit-beacon-header { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.cockpit-beacon-header .live-beacon { width: 10px; height: 10px; border-radius: 50%; }
.cockpit-beacon-header .live-beacon::after { display: none; }
.cockpit-beacon-info { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); }

.cockpit-side-box { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cockpit-side-box:has(#plano-aviso:empty) { display: none; }
.cockpit-side-titulo { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-foreground); }
.cockpit-side-texto { margin: 0; font-size: 12.5px; color: var(--muted-foreground); line-height: 1.5; }
.cockpit-side-acoes { display: flex; flex-direction: column; gap: 6px; }
.cockpit-side-rotulo { font-size: 11px; color: var(--muted-foreground); margin-top: 4px; }
.cockpit-side-token code {
  display: block; font-size: 11px; word-break: break-all; user-select: all;
  background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
}

.cockpit-nav-menu { display: flex; flex-direction: column; gap: 4px; }
.cockpit-nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted-foreground); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.cockpit-nav-btn:hover { color: var(--foreground); background: var(--muted); }
.cockpit-nav-btn.active { color: var(--foreground); border-color: var(--border); background: var(--muted); }

/* ── tabela de chips ──────────────────────────────────────────────────── */
.bloomberg-box { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: color-mix(in oklab, var(--background) 60%, black); }
.bloomberg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bloomberg-table th {
  padding: 12px 14px; text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-foreground); border-bottom: 1px solid var(--border);
}
.bloomberg-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.bloomberg-table tbody tr:last-child td { border-bottom: 0; }
.bloomberg-table tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }

.badge-status-dot { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 99px; white-space: nowrap; }
.badge-status-dot .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status-dot.connected { color: var(--primary); border-color: color-mix(in oklab, var(--primary) 40%, transparent); }
.badge-status-dot.waiting { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, transparent); }
.badge-status-dot.offline { color: var(--muted-foreground); }

.btn-action-sm {
  height: 28px; padding: 0 10px; border-radius: 6px; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--input); background: transparent; color: var(--foreground);
}
.btn-action-sm:hover { background: var(--muted); }
.btn-action-sm.btn-del { color: var(--destructive) !important; border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }

/* ── logs ─────────────────────────────────────────────────────────────── */
.activity-feed-card { overflow: hidden; }
.feed-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-foreground);
}
.feed-header .live-beacon { width: 8px; height: 8px; border-radius: 50%; }
.feed-header .live-beacon::after { display: none; }
.feed-body { max-height: 340px; overflow-y: auto; padding: 8px 16px 12px; font-family: var(--font-mono); font-size: 11.5px; }
.stream-line { display: flex; gap: 8px; padding: 3px 0; }
.stream-line .ts { color: var(--muted-foreground); flex: none; }
.stream-line .tag { flex: none; color: var(--muted-foreground); }
.stream-line .tag.connected, .stream-line .msg.connected, .stream-line .tag.outbound { color: var(--primary); }
.stream-line .tag.disconnected, .stream-line .msg.disconnected { color: var(--destructive); }
.stream-line .tag.inbound { color: var(--warn); }
.stream-line .msg { color: var(--foreground); word-break: break-word; }

/* ── modal do QR ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 16px;
  background: color-mix(in oklab, black 70%, transparent); backdrop-filter: blur(6px);
}
.modal-overlay.active, .modal-overlay.open { display: grid; }
.modal-box { width: 100%; max-width: 420px; padding: 24px; background: var(--card); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 26px; letter-spacing: -0.01em; }
.modal-close-btn { border: 0; background: transparent; color: var(--muted-foreground); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close-btn:hover { color: var(--foreground); }
.qr-frame { position: relative; display: inline-block; padding: 10px; border-radius: 8px; background: #fff; }
.qr-frame img { display: block; width: 220px; height: 220px; }
.qr-laser-line { display: none; }

/* ── entrar ───────────────────────────────────────────────────────────── */
.entrar-card { width: 100%; max-width: 400px; padding: 28px; }
.entrar-logo { margin-bottom: 20px; }
.entrar-abas { display: flex; gap: 6px; margin-bottom: 20px; }
.entrar-aba {
  flex: 1; height: 36px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--muted-foreground); font: inherit; font-size: 13px; cursor: pointer;
}
.entrar-aba[aria-selected="true"] { color: var(--foreground); border-color: var(--input); background: var(--muted); }
.entrar-form { display: flex; flex-direction: column; gap: 12px; }
.entrar-form label { font-size: 12px; color: var(--muted-foreground); }
.entrar-dica { font-size: 12px; color: var(--muted-foreground); margin: 0; line-height: 1.5; }
.entrar-link { font-size: 12px; color: var(--muted-foreground); text-decoration: underline; align-self: center; }
.entrar-link:hover { color: var(--foreground); }
.entrar-msg { font-size: 13px; margin: 14px 0 0; line-height: 1.5; min-height: 1em; }
.entrar-msg.erro { color: var(--destructive); }
.entrar-msg.ok { color: var(--primary); }
body.pagina-entrar { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }

/* ── mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .operator-workspace-grid { grid-template-columns: 1fr; padding: 16px; }
  .cockpit-sidebar { position: static; }
  .app-header { padding: 0 16px; height: auto; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
  .app-badge { display: none; }
}

/* Aviso "confirme seu e-mail" no topo do painel (cockpit.js → mostrarAvisoVerificacao). */
.aviso-verificacao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border-hairline);
  border-left: 3px solid var(--accent-primary);
  color: var(--text-main);
  font-size: 13px;
}
.aviso-verificacao[hidden] { display: none; }
.aviso-verificacao-btn {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--accent-primary);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}
.aviso-verificacao-btn:disabled { opacity: .5; cursor: default; }
