/* =========================================================
   Tools KJ — v3: HUD de trader com LEDs
   Paleta: fundo azul-espacial quase-preto, dourado (ação/
   destaque principal) + ciano elétrico (dados/gráficos),
   verde/vermelho reservados exclusivamente pra lucro/risco.
   Cards com canto cortado (clip-path) + friso de gradiente,
   LEDs pulsantes em pontos de status, glow nos elementos
   de ação — pensado pra parecer um painel de cockpit.
   ========================================================= */

:root {
  --bg-0: #05060c;
  --bg-1: #0b0e17;
  --bg-2: #121826;
  --border: #232c3d;
  --text-0: #eef1f6;
  --text-1: #8993a4;
  --gold: #f0b429;
  --gold-soft: rgba(240, 180, 41, 0.14);
  --cyan: #2fe0f5;
  --cyan-soft: rgba(47, 224, 245, 0.12);
  --green: #26e08a;
  --red: #ff4d68;
  --font-display: 'Chakra Petch', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 4px;
  --cut: 14px; /* tamanho do corte angular dos cards */
}

/* ---------- Tema claro ---------- */
[data-theme="light"] {
  --bg-0: #eef1f5;
  --bg-1: #ffffff;
  --bg-2: #f2f4f7;
  --border: #dde2e8;
  --text-0: #161b22;
  --text-1: #5b6572;
  --gold: #c08a12;
  --gold-soft: rgba(192, 138, 18, 0.12);
  --cyan: #0e93a3;
  --cyan-soft: rgba(14, 147, 163, 0.10);
  --green: #16a35e;
  --red: #d9354c;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 900px 500px at 10% -10%, rgba(192, 138, 18, 0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(14, 147, 163, 0.05), transparent 60%);
}

[data-theme="light"] .btn { color: #241a00; }
[data-theme="light"] .toggle-group button.active { color: #241a00; }
[data-theme="light"] .card::before,
[data-theme="light"] .led-dot,
[data-theme="light"] .btn { box-shadow: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 10% -10%, rgba(240, 180, 41, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(47, 224, 245, 0.09), transparent 60%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app-shell { display: flex; min-height: 100vh; max-width: 100vw; }

/* ---------- LED pulsante (indicador de status/"sistema online") ---------- */
@keyframes led-pulso {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px 1px currentColor, 0 0 12px 2px currentColor; }
  50% { opacity: 0.55; box-shadow: 0 0 2px 0px currentColor, 0 0 6px 1px currentColor; }
}
.led-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  color: var(--green);
  animation: led-pulso 2s ease-in-out infinite;
  flex-shrink: 0;
}
.led-dot.gold { color: var(--gold); }
.led-dot.cyan { color: var(--cyan); }
.led-dot.red { color: var(--red); }
.led-dot.off { color: var(--text-1); animation: none; box-shadow: none; opacity: 0.5; }

/* ---------- Logo ---------- */
.logo-mark { display: flex; align-items: center; gap: 10px; }
.logo-mark img { flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(38, 224, 138, 0.35)); }
.logo-mark .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.logo-mark .logo-text span { color: var(--gold); }
.logo-mark .logo-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-1);
  text-transform: uppercase;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 44px;
}

.nav-item:hover { background: var(--bg-2); color: var(--text-0); }
.nav-item.active {
  background: var(--gold-soft);
  color: var(--gold);
  border-left-color: var(--gold);
  box-shadow: inset 3px 0 8px -4px var(--gold);
}

/* ---------- Topo mobile (hamburger) ---------- */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.mobile-actions { display: flex; align-items: center; gap: 8px; }

.hamburger-btn {
  width: 44px; height: 44px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger-btn span { display:block; width: 18px; height: 2px; background: var(--text-0); }
.hamburger-btn:hover, .hamburger-btn:active { border-color: var(--gold); }

.theme-toggle-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-1);
  flex-shrink: 0;
}
.theme-toggle-btn:hover, .theme-toggle-btn:active { border-color: var(--gold); color: var(--gold); }
.theme-toggle-btn svg { width: 18px; height: 18px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  margin-bottom: 22px;
}
.sidebar-header .logo-mark { margin-bottom: 0; }

.sidebar-close-btn {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
  z-index: 45;
}
.sidebar-overlay.open { display: block; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; max-width: 100%; padding: 28px 32px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.page-subtitle { color: var(--text-1); font-size: 13px; margin-top: 2px; }

/* ---------- Card (canto cortado, friso superior com glow) ---------- */
.card {
  position: relative;
  background: linear-gradient(165deg, var(--bg-1), var(--bg-1) 70%, var(--bg-2));
  border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  padding: 20px 22px;
  max-width: 100%;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: var(--cut);
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--cyan));
  box-shadow: 0 0 8px 0 rgba(240, 180, 41, 0.5), 0 0 8px 0 rgba(47, 224, 245, 0.4);
}

.card:hover { border-color: #33405a; }

.card + .card { margin-top: 20px; }

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-0);
  margin: 0 0 16px;
  text-transform: uppercase;
}

.grid { display: grid; gap: 20px; max-width: 100%; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ---------- stat-card com glow neon ---------- */
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.stat-card .stat-label {
  font-size: 12px; color: var(--text-1); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.stat-card .stat-valor { font-family: var(--font-mono); font-size: 26px; font-weight: 700; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 16px; /* nunca menor que 16px: abaixo disso o iOS Safari dá zoom sozinho ao focar */
  padding: 12px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.toggle-group {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.toggle-group button {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: 3px;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.15s, color 0.15s;
}

.toggle-group button.active { background: var(--gold); color: #1a1200; box-shadow: 0 0 10px rgba(240, 180, 41, 0.5); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(100deg, var(--gold), #ffce5c);
  color: #1a1200;
  font-weight: 700;
  font-size: 14px;
  border: none;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  padding: 13px 18px;
  min-height: 46px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  width: 100%;
  box-shadow: 0 0 16px rgba(240, 180, 41, 0.35);
}

.btn:hover { filter: brightness(1.1); box-shadow: 0 0 22px rgba(240, 180, 41, 0.55); }
.btn:active { transform: scale(0.98); }

/* ---------- Resultado do risco ---------- */
.risco-result {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.risco-result .label { font-size: 12px; color: var(--text-1); text-transform: uppercase; letter-spacing: 0.05em; }
.risco-result .valor { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: var(--red); }
.risco-result.baixo .valor { color: var(--green); text-shadow: 0 0 12px rgba(38, 224, 138, 0.5); }
.risco-result.medio .valor { color: var(--gold); text-shadow: 0 0 12px rgba(240, 180, 41, 0.5); }

/* ---------- Painel de sessões (relógio) ---------- */
.sessoes-clock-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; justify-content: center; }
.sessoes-clock { width: 250px; height: 250px; flex-shrink: 0; max-width: 100%; }
.sessoes-lista { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }

.sessao-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 14px;
  flex-wrap: wrap;
}

.sessao-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-1); flex-shrink: 0; }
.sessao-item.ativa { border-color: var(--gold); background: var(--gold-soft); }
.sessao-item.ativa .sessao-dot { background: var(--gold); box-shadow: 0 0 4px var(--gold), 0 0 10px var(--gold); animation: led-pulso 1.6s ease-in-out infinite; }
.sessao-nome { flex: 1; color: var(--text-0); font-weight: 600; }
.sessao-horario { color: var(--text-1); }
.sessao-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-1); }
.sessao-item.ativa .sessao-status { color: var(--gold); }

/* =========================================================
   Responsivo — tablets e celulares
   ========================================================= */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: 21px; }
  .card { padding: 16px; }

  .sidebar.mobile-open {
    display: flex;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    width: 82%;
    max-width: 300px;
    box-shadow: 8px 0 40px rgba(0,0,0,0.6);
    overflow-y: auto;
  }
  .sidebar-close-btn { display: flex; }

  /* botões de ação em tabelas: empilham e ficam com alvo de toque maior */
  .actions-cell {
    flex-direction: column;
    align-items: stretch;
  }
  .actions-cell form, .actions-cell a.btn-sm { width: 100%; }
  .btn-sm { min-height: 40px; justify-content: center; }
}

@media (max-width: 640px) {
  .sessoes-clock { width: 210px; height: 210px; }
  .logo-mark .logo-text { font-size: 17px; }
}
