/* ============================================================
   ORION DEMON — componentes
   Botões, pílulas, badges, cards, campos, switch, tabs, tabela,
   vazio, toasts, palette, modal, drawer, menu de contexto.
   Os nomes antigos (.card, .demon-btn, .badge…) são mantidos porque
   o HTML dos plugins depende deles.
   ============================================================ */

/* ---------- botões ---------- */
.btn, .mini-btn, .demon-btn, .btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600; font-size: var(--fs-sm); letter-spacing: .06em;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover, .mini-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.btn:active, .mini-btn:active, .demon-btn:active, .btn-primary:active { transform: translateY(1px); }
.btn:disabled, .mini-btn:disabled, .btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.mini-btn { padding: 6px 11px; font-size: var(--fs-xs); color: var(--muted); }
.mini-btn:hover { color: var(--ink); }

.btn-primary, .demon-btn {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
  letter-spacing: .1em;
}
.btn-primary:hover, .demon-btn:hover { filter: brightness(1.08); }
.demon-btn { margin-top: 8px; padding: 9px 16px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

.btn-danger { border-color: rgba(255,59,82,.4); color: #ff9caa; background: rgba(255,59,82,.08); }
.btn-danger:hover { background: rgba(255,59,82,.18); color: #fff; }

.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); font-size: 15px; }

.kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--void-2);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
}

/* ---------- pílulas e badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono); font-size: var(--fs-xs);
}
.pill .k { color: var(--faint); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; }
.pill .v { color: var(--ink); font-weight: 600; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid;
  line-height: 1.4;
}
.badge.run     { color: var(--ok);   border-color: rgba(53,208,127,.4); background: rgba(53,208,127,.1); }
.badge.stop    { color: var(--faint); border-color: var(--line); background: rgba(255,255,255,.03); }
.badge.err     { color: var(--err);  border-color: rgba(255,59,82,.4); background: rgba(255,59,82,.1); }
.badge.warn    { color: var(--warn); border-color: rgba(255,176,46,.4); background: rgba(255,176,46,.1); }
.badge.legacy  { color: var(--secondary); border-color: var(--line-strong); background: var(--grad-soft); }
.badge.info    { color: var(--info); border-color: rgba(127,216,255,.35); background: rgba(127,216,255,.08); }
.badge.mobile  { color: var(--magenta); border-color: rgba(224,64,251,.35); background: rgba(224,64,251,.08); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.dot.off { background: var(--faint); }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.grad-border { border-color: transparent; }
.card .card-label, .card-label {
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.card .big, .big {
  font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.card .big small, .big small { font-size: 15px; color: var(--muted); font-weight: 500; }

/* ---------- campos ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px;
  font-family: var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--track-label);
  text-transform: uppercase; color: var(--muted);
}
.field input, .field select, .field textarea, .input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-mono); font-size: var(--fs-md);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px var(--focus);
}
.field input::placeholder, .input::placeholder { color: var(--faint); }
input[type="color"].swatch { width: 40px; height: 32px; padding: 2px; border-radius: 6px; border: 1px solid var(--line); background: var(--void-2); }

/* ---------- switch ---------- */
.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 1px solid var(--line); transition: background .2s, border-color .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s;
}
.switch input:checked + .slider { background: var(--grad-soft); border-color: var(--line-strong); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--primary); }
.switch input:disabled + .slider { opacity: .4; cursor: not-allowed; }

/* ---------- tabs / chips ---------- */
.tabs, .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.active { color: var(--ink); background: var(--surface-3); border-color: var(--line-strong); }
.chip[data-level="ERROR"].active { color: var(--err); border-color: rgba(255,59,82,.5); }
.chip[data-level="WARNING"].active { color: var(--warn); border-color: rgba(255,176,46,.5); }
.chip[data-level="MODULE"].active { color: var(--ok); border-color: rgba(53,208,127,.5); }
.chip[data-level="SYSTEM"].active { color: var(--info); border-color: rgba(127,216,255,.5); }

/* ---------- tabela ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; padding: 9px 12px;
  font-family: var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--track-label);
  text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: var(--surface-2); }
.table .mono { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }

/* ---------- vazio ---------- */
.empty {
  color: var(--faint); font-family: var(--font-mono); font-size: var(--fs-sm);
  padding: 40px 20px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty b { color: var(--muted); }

/* ---------- cabeçalho de página ---------- */
.view-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; }
.view-head p { color: var(--muted); font-size: var(--fs-sm); flex-basis: 100%; }
.view-head .spacer { flex: 1; }
.view-head .actions { display: flex; gap: 8px; margin-left: auto; }

.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.panels { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 16px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: calc(var(--dock-h) + 14px); display: flex; flex-direction: column; gap: 8px; z-index: 900; }
.toast {
  min-width: 240px; max-width: 360px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: var(--fs-sm);
  border-left: 3px solid var(--secondary);
  animation: slide-right .25s ease both;
  display: flex; gap: 10px; align-items: flex-start;
}
.toast .src { font-family: var(--font-mono); font-size: 10px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--err); }
.toast.warning { border-left-color: var(--warn); }
.toast.info    { border-left-color: var(--secondary); }
.toast.leaving { opacity: 0; transform: translateX(20px); transition: all .3s; }
/* 4.5: pergunta com botões (Angela, testes de entrega…) */
.toast.question { flex-direction: column; gap: 6px; max-width: 400px; border-left-color: #60a5fa; }
.toast.question.critical, .toast.question.error { border-left-color: var(--err); }
.toast.question .src { margin: 0; }
.notif-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.notif-actions button { padding: 5px 11px; font-size: var(--fs-xs); border-radius: 8px; }
.notif-actions .ghost { background: transparent; border-color: transparent; }
.notif-answer { margin-top: 6px; font-size: var(--fs-xs); color: var(--ok); }
.notif-answer.muted { color: var(--faint); }
.notif.urgent { border-color: rgba(255,59,82,.5); }

/* ---------- overlays ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(4, 2, 8, .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  animation: fade-in .15s ease both;
}
.backdrop.center { align-items: center; }

/* palette */
.palette {
  width: min(92vw, 640px); margin-top: 12vh;
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-win); overflow: hidden;
  animation: pop-in .15s ease both;
}
.palette input {
  width: 100%; padding: 16px 18px;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  color: var(--ink); font-family: var(--font-mono); font-size: 15px; outline: none;
}
.palette input::placeholder { color: var(--faint); }
.palette .list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .item {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--muted);
}
.palette .item .ico { text-align: center; font-size: 15px; }
.palette .item .title { color: var(--ink); font-size: var(--fs-md); }
.palette .item .sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.palette .item.active { background: var(--grad-soft); outline: 1px solid var(--line-strong); }
.palette .item.danger .title { color: #ff9caa; }
.palette .foot {
  display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint);
}
.palette .group {
  padding: 8px 12px 2px; font-family: var(--font-display); font-size: 10px; letter-spacing: var(--track-label);
  text-transform: uppercase; color: var(--faint);
}

/* modal */
.modal {
  width: min(92vw, 560px); margin-top: 14vh;
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-win); animation: pop-in .15s ease both;
  display: flex; flex-direction: column; max-height: 80vh;
}
.modal .head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .head h3 { flex: 1; font-size: var(--fs-lg); }
.modal .body { padding: 18px; overflow-y: auto; color: var(--ink); font-size: var(--fs-md); line-height: 1.6; }
.modal .body p { color: var(--muted); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal.danger .head h3 { color: #ff9caa; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 790; background: rgba(4,2,8,.35); animation: fade-in .15s both; }
.drawer {
  position: fixed; top: 0; bottom: 0; width: min(92vw, 420px); z-index: 795;
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border-left: 1px solid var(--line-strong); box-shadow: var(--shadow-win);
  display: flex; flex-direction: column;
  transition: transform .2s ease;
}
.drawer.right { right: 0; animation: slide-right .2s ease both; }
.drawer.left { left: 0; border-left: none; border-right: 1px solid var(--line-strong); }
.drawer .head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer .head h3 { flex: 1; font-size: var(--fs-lg); }
.drawer .body { flex: 1; overflow-y: auto; padding: 14px 16px; }

/* menu de contexto */
.ctx-menu {
  position: fixed; z-index: 950; min-width: 190px;
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-win); padding: 5px;
  animation: pop-in .1s ease both;
}
.ctx-menu .item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  font-size: var(--fs-sm); color: var(--ink); cursor: pointer; white-space: nowrap;
}
.ctx-menu .item:hover { background: var(--surface-3); }
.ctx-menu .item.danger { color: #ff9caa; }
.ctx-menu .item .ico { width: 18px; text-align: center; color: var(--muted); }
.ctx-menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }
.ctx-menu .title { padding: 6px 10px 2px; font-family: var(--font-display); font-size: 10px; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--faint); }

/* menu dropdown genérico (workspace switcher, usuário) */
.dropdown { position: relative; }
.dropdown .menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 700;
  min-width: 220px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto;
  background: var(--surface); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-win); padding: 5px; animation: pop-in .12s ease both;
}
.dropdown .menu.left { right: auto; left: 0; }
.dropdown .menu .item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; font-size: var(--fs-sm); cursor: pointer; color: var(--ink); }
.dropdown .menu .item:hover { background: var(--surface-3); }
.dropdown .menu .item.active { background: var(--grad-soft); }
.dropdown .menu .item .ico { width: 18px; text-align: center; }
.dropdown .menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* notificações (lista reutilizada no drawer e na página) */
.notif-list { display: flex; flex-direction: column; gap: 6px; }
.notif {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.notif .dot { margin-top: 6px; }
.notif .msg { font-size: var(--fs-sm); color: var(--ink); }
.notif .meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.notif .time { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.notif.unread { border-color: var(--line-strong); }
