/* Paleta omnismart: roxo do logo + branco. O tema segue o do Teams (default / dark / contrast). */
:root,
:root[data-theme="default"] {
  --brand-deep: #261a5c;      /* fundo do logo */
  --brand: #4f35c2;
  --brand-hover: #3f2aa3;
  --brand-tint: #ece8fb;
  --on-brand: #ffffff;
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f1eff9;
  --text: #1d1838;
  --muted: #6b6788;
  --border: #e2def2;
  --ok: #13a10e;
  --danger: #d13438;
  --warn: #c19c00;
  --shadow: 0 1px 2px rgba(38, 26, 92, .06), 0 4px 16px rgba(38, 26, 92, .08);
}

:root[data-theme="dark"] {
  --brand-deep: #1a1240;
  --brand: #8b74f2;
  --brand-hover: #a08cf5;
  --brand-tint: #2c2260;
  --on-brand: #ffffff;
  --bg: #141026;
  --surface: #1e1838;
  --surface-2: #261f47;
  --text: #f3f1fb;
  --muted: #a7a2c4;
  --border: #322a5c;
  --ok: #54b054;
  --danger: #f1707b;
  --warn: #f2c94c;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
}

:root[data-theme="contrast"] {
  --brand-deep: #000000;
  --brand: #ffff00;
  --brand-hover: #ffff66;
  --brand-tint: #000000;
  --on-brand: #000000;
  --bg: #000000;
  --surface: #000000;
  --surface-2: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --border: #ffffff;
  --ok: #3ff23f;
  --danger: #ff6b6b;
  --warn: #ffff00;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--brand-deep); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 24px; height: 24px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .12); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); white-space: nowrap;
  max-width: 55vw; overflow: hidden; text-overflow: ellipsis;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #9a96b3; flex: none; }
.status-ok .dot { background: #4ade80; }
.status-connecting .dot { background: #facc15; animation: pulse 1s infinite; }
.status-error .dot { background: #f87171; }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 420px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow);
}

/* Login */
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 16px; font-size: 14px; }
form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
form input:not([type="checkbox"]) {
  display: block; width: 100%; margin-top: 4px;
  padding: 9px 12px; font: inherit; font-weight: 400; font-size: 14px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; outline: none;
}
form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.advanced { margin: 4px 0 12px; font-size: 13px; }
.advanced summary { cursor: pointer; color: var(--brand); margin-bottom: 10px; font-weight: 600; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 10px 0 0; }

.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; padding: 4px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

#view-phone { display: grid; gap: 12px; }

/* Avisos */
.banner {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  background: var(--brand-tint); color: var(--text); border: 1px solid var(--border);
}
.btn-sm { padding: 6px 12px; font-size: 13px; flex: none; }

/* Diagnóstico */
.diag { padding: 16px 8px 8px; }
.diag h2 { font-size: 14px; margin: 0; }
.diag pre {
  margin: 0; padding: 8px 12px; max-height: 260px; overflow: auto;
  font: 11px/1.5 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; word-break: break-word;
  color: var(--muted);
}

/* Discador */
.dialer { display: grid; gap: 16px; justify-items: center; }
.number-row { display: flex; align-items: center; width: 100%; gap: 4px; }
.number {
  flex: 1; min-width: 0; text-align: center; font-size: 26px; font-weight: 600; letter-spacing: 1px;
  border: 0; border-bottom: 2px solid var(--border); background: transparent; color: var(--text);
  padding: 6px 0; outline: none; font-family: inherit;
}
.number:focus { border-bottom-color: var(--brand); }

.keypad { display: grid; grid-template-columns: repeat(3, 64px); gap: 12px 20px; justify-content: center; }
.key {
  width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  display: grid; place-content: center; line-height: 1; font-family: inherit;
  transition: background .12s, transform .06s;
}
.key:hover { background: var(--brand-tint); }
.key:active { transform: scale(.94); }
.key b { font-size: 24px; font-weight: 500; }
.key small { font-size: 9px; letter-spacing: 1.5px; color: var(--muted); margin-top: 3px; min-height: 9px; }
.keypad-sm { grid-template-columns: repeat(3, 52px); gap: 8px 14px; margin: 8px 0 4px; }
.keypad-sm .key { width: 52px; height: 52px; }
.keypad-sm .key b { font-size: 20px; }

.call-btn, .round {
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; transition: filter .12s, transform .06s;
}
.call-btn { background: var(--ok); }
.call-btn:hover, .round:hover { filter: brightness(1.08); }
.call-btn:active, .round:active { transform: scale(.94); }
.call-btn svg, .round svg { width: 26px; height: 26px; }
.round-ok { background: var(--ok); }
.round-danger { background: var(--danger); }
.rot { transform: rotate(135deg); transform-origin: 12px 12px; }
:root[data-theme="contrast"] .call-btn, :root[data-theme="contrast"] .round { color: #000; }

/* Histórico */
.history { padding: 16px 8px 8px; }
.history-head { display: flex; justify-content: space-between; align-items: center; padding: 0 12px 8px; }
.history h2 { font-size: 14px; margin: 0; }
#history-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
#history-list li {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
#history-list li:hover { background: var(--surface-2); }
.h-icon { width: 18px; height: 18px; flex: none; }
.h-in { color: var(--ok); } .h-out { color: var(--brand); } .h-missed { color: var(--danger); }
.h-main { flex: 1; min-width: 0; }
.h-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-meta { font-size: 12px; color: var(--muted); }
#history-empty { font-size: 13px; margin: 8px 0 12px; }

/* Overlay de chamada */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: linear-gradient(160deg, var(--brand-deep), #3a2788);
  display: grid; place-items: center; padding: 16px; color: #fff;
}
:root[data-theme="contrast"] .overlay { background: #000; }
.call-panel { width: 100%; max-width: 360px; display: grid; justify-items: center; text-align: center; gap: 6px; }
.avatar {
  width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); font-size: 32px; font-weight: 600; margin-bottom: 8px;
}
.avatar.ringing { animation: ring 1.4s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 100% { box-shadow: 0 0 0 26px rgba(255,255,255,0); } }
.call-name { font-size: 22px; font-weight: 600; word-break: break-word; }
.call-number { font-size: 14px; opacity: .8; }
.call-state { font-size: 14px; opacity: .9; min-height: 20px; margin-bottom: 18px; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; justify-content: center; gap: 48px; margin-top: 16px; }

.call-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.tool {
  display: grid; justify-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px;
  background: rgba(255, 255, 255, .1); border: 0; color: #fff; font: inherit; font-size: 12px; cursor: pointer;
}
.tool:hover { background: rgba(255, 255, 255, .18); }
.tool[aria-pressed="true"] { background: #fff; color: var(--brand-deep); }
.overlay .key { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.overlay .key small { color: rgba(255, 255, 255, .7); }
.transfer { display: flex; gap: 8px; width: 100%; margin-top: 12px; }
.transfer input {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3);
  background: rgba(255, 255, 255, .1); color: #fff; font: inherit; outline: none;
}
.transfer input::placeholder { color: rgba(255, 255, 255, .6); }
.overlay .btn-primary { background: #fff; color: var(--brand-deep); }
