/* =============================================================================
   Painel do SIP Proxy — marca ConnPBX
   Mesmos tokens e mesma fonte do painel do nó (newpbx.connpbx.com.br,
   /opt/vpbx-gateway/web/app.css): claro por padrão, escuro por classe .dark
   no <html>, construído sobre o Azul Profundo. As classes são as que o
   app.js deste painel já gera (.panel, .stat, .badge.on, #tabs...).
   ========================================================================== */

@font-face {
  font-family: 'Geist Variable'; font-style: normal; font-display: swap;
  font-weight: 100 900;
  src: url(/assets/geist-latin-wght-normal-Dm3htQBi.woff2) format('woff2-variations');
}
@font-face {
  font-family: 'Geist Mono Variable'; font-style: normal; font-display: swap;
  font-weight: 100 900;
  src: url(/assets/geist-mono-latin-wght-normal-Cjtb1TV-.woff2) format('woff2-variations');
}

:root {
  /* neutros — escala CINZA da tabela da marca */
  --background: #FFFFFF;
  --foreground: #061023;            /* Azul de Contraste: texto sobre fundo claro */
  --card: #FFFFFF;
  --subtle: #F5F5F5;                /* Cinza Leve: lateral, áreas de respiro */
  --muted: #E5E5E5;                 /* Cinza Base */
  --muted-foreground: #707070;      /* Cinza Escuro: textos de apoio */
  --border: #E5E5E5;
  --input-bg: #FFFFFF;
  --accent: #DCE2ED;                /* Azul Leve: item ativo da lateral */
  --accent-foreground: #13306C;     /* Azul Hover/Ação */

  /* marca — LARANJA é a cor de CTA segundo a tabela */
  --primary: #FF6049;               /* Laranja Vibrante */
  --primary-hover: #CC4C38;         /* Laranja Escuro */
  --primary-pressed: #A33627;       /* Laranja de Contraste */
  --primary-foreground: #FFFFFF;

  /* semânticas (fora da tabela): perigo bem mais escuro que o laranja,
     senão "apagar" e "salvar" ficam com a mesma cara */
  --success: #1A7F37;
  --warning: #9A6700;
  --info: #13306C;
  --destructive: #B3261E;

  --radius-sm: .25rem;
  --radius-md: .375rem;
  --font-sans: 'Geist Variable', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
  --t: .15s cubic-bezier(.4, 0, .2, 1);
}

.dark {
  --background: #0A1C3F;            /* Azul Profundo */
  --foreground: #EDF1F7;
  --card: #10254B;
  --subtle: #081831;
  --muted: #223356;                 /* Azul Médio */
  --muted-foreground: #A8B4CA;
  --border: #223356;
  --input-bg: #081831;
  --accent: #13306C;
  --accent-foreground: #DCE2ED;
  /* o laranja NÃO muda no escuro: é a assinatura da marca */
  --success: #3FB27F;
  --warning: #E3B341;
  --info: #7AA2E3;
  --destructive: #E5484D;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
html.dark { color-scheme: dark; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted-foreground); }
.err { color: var(--destructive); min-height: 18px; margin-top: 8px; font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* -------------------------------------------------------------- botões --- */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  padding: .45rem .8rem; border-radius: var(--radius-md); border: 1px solid transparent;
  background: var(--primary); color: var(--primary-foreground);
  transition: background var(--t), border-color var(--t), color var(--t), opacity var(--t);
}
button:hover { background: var(--primary-hover); }
button:active { background: var(--primary-pressed); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.secondary { background: var(--card); color: var(--foreground); border-color: var(--border); }
button.secondary:hover { background: var(--muted); }
button.link { background: none; color: var(--muted-foreground); padding: .25rem .5rem; border: 0; }
button.link:hover { background: var(--muted); color: var(--foreground); }
button.danger { background: var(--destructive); color: #fff; }
button.danger:hover { background: var(--destructive); opacity: .88; }
button.mini { padding: .275rem .55rem; font-size: 12px; }

/* ---------------------------------------------------------- formulários --- */
label { display: block; font-size: 12px; font-weight: 500; margin: .7rem 0 .3rem; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; margin: 0;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--input-bg); color: var(--foreground); font: inherit; font-size: 14px;
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; line-height: 1.5; }
.panel-head .head-btns { display: flex; gap: 8px; }
.modal .hint {
  margin: 2px 0 6px; color: var(--muted-foreground); font-size: 12.5px; line-height: 1.5;
  background: var(--subtle); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 11px;
}
.modal .hint b { color: var(--foreground); }
.modal input[type=file] { padding: 7px; font-size: 13px; }

/* ---------------------------------------------------------------- login --- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: var(--subtle); }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 2rem;
}
.login-brand { margin-bottom: 1.75rem; }
.login-card h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.login-card p { margin: .15rem 0 .75rem; font-size: 13px; }
.login-card button { width: 100%; margin-top: 1.1rem; padding: .55rem .8rem; }

/* logo: duas imagens, uma por tema; a troca é por CSS e não pisca */
.brand-logo { width: 220px; height: auto; display: block; }
.brand-logo-dark { display: none; }
.dark .brand-logo-light { display: none; }
.dark .brand-logo-dark { display: block; }
.brand-mark-img { width: 30px; height: auto; display: block; }
.brand-mark-dark { display: none; }
.dark .brand-mark-light { display: none; }
.dark .brand-mark-dark { display: block; }

/* ------------------------------------------------------- app + lateral --- */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100dvh; }
.side {
  background: var(--subtle); border-right: 1px solid var(--border);
  padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: .625rem; margin: .25rem .25rem 1.25rem; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -.01em; line-height: 1.25; }
.brand-sub { color: var(--muted-foreground); font-size: 12px; }

#tabs { display: flex; flex-direction: column; gap: .15rem; }
#tabs button {
  justify-content: flex-start; width: 100%; text-align: left;
  padding: .4rem .55rem; border: 0; background: none;
  color: var(--muted-foreground); font-size: 13px; font-weight: 400;
}
#tabs button:hover { background: var(--muted); color: var(--foreground); }
#tabs button.active { background: var(--accent); color: var(--accent-foreground); font-weight: 500; }

.side-foot {
  margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch; gap: .1rem;
}
.side-foot button.link { justify-content: flex-start; font-size: 12.5px; }
#who { color: var(--muted-foreground); font-size: 12px; padding: 0 .5rem .35rem; }

main { padding: 1.25rem 1.5rem; max-width: 1240px; width: 100%; min-width: 0; }

/* ---------------------------------------------------- dashboard / cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem 1.1rem; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.stat .l { color: var(--muted-foreground); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-top: .3rem; }
.stat.ok .n { color: var(--success); }
.stat.acc .n { color: var(--primary); }
.stat.warn .n { color: var(--warning); }
.stat.off .n { color: var(--muted-foreground); }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 1.1rem; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-body { padding: 0; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted-foreground); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: var(--subtle); }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: 6px; }
.empty { padding: 2.5rem; text-align: center; color: var(--muted-foreground); font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .5rem; border-radius: var(--radius-sm);
  font-size: 11.5px; font-weight: 500; font-family: var(--font-mono);
  background: var(--muted); color: var(--muted-foreground);
}
.badge.on { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.badge.off { background: var(--muted); color: var(--muted-foreground); }
.badge.call { background: var(--accent); color: var(--accent-foreground); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--success); }
.dot.off { background: var(--muted-foreground); }

/* ---------------------------------------------------------------- modal --- */
.modal-wrap { position: fixed; inset: 0; background: rgb(0 0 0 / .5); display: grid; place-items: center; padding: 1.5rem; z-index: 20; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1.25rem; width: 420px; max-width: 100%; max-height: 88dvh; overflow-y: auto;
}
.modal h3 { margin: 0 0 .5rem; font-size: 15px; font-weight: 600; }
.modal label { color: var(--foreground); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--border); }

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 30;
  background: var(--card); color: var(--foreground); border: 1px solid var(--border);
  border-left: 3px solid var(--success); padding: .75rem 1rem; border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.toast.err { border-left-color: var(--destructive); }

/* ----------------------------------------------- busca, filtro, páginas --- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); }
.toolbar input { margin: 0; max-width: 300px; }
.toolbar .grow { flex: 1; }
.seg { display: flex; gap: 4px; }
.seg button { background: var(--card); color: var(--muted-foreground); border: 1px solid var(--border); padding: .35rem .75rem; font-size: 12.5px; }
.seg button:hover { color: var(--foreground); background: var(--muted); }
.seg button.active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: .8rem; }
.pager button { background: var(--card); border: 1px solid var(--border); color: var(--foreground); }
.pager button:hover:not(:disabled) { background: var(--muted); }
.pager button:disabled { opacity: .4; cursor: default; }
.refresh { color: var(--muted-foreground); font-size: 12px; }

/* ------------------------------------------------------- detalhe do ramal --- */
button.badge { border: 1px solid transparent; line-height: 1.5; padding: .1rem .5rem; }
button.badge.on:hover { background: color-mix(in srgb, var(--success) 26%, transparent); border-color: var(--success); }
.modal.wide { width: 780px; }
.modal.wide table th, .modal.wide table td { padding: 7px 9px; font-size: 12.5px; }
.det-h { margin: 14px 0 6px; color: var(--muted-foreground); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.det-box { background: var(--subtle); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 11px 13px; margin-bottom: 8px; }
.det-tag { color: var(--muted-foreground); font-size: 12px; margin-bottom: 7px; }
.det-warn {
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--destructive) 40%, transparent);
  color: var(--foreground); border-radius: var(--radius-md); padding: 10px 13px; margin-top: 10px; font-size: 13px; line-height: 1.5;
}
.det-bad { color: var(--destructive); font-weight: 600; }
.det-foot { display: flex; justify-content: flex-start; margin-top: 12px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 5px 12px; font-size: 13px; align-items: baseline; }
.kv .k { color: var(--muted-foreground); }
.kv .v { word-break: break-all; }

/* --------------------------------------------------------------- celular --- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  #tabs { flex-direction: row; flex-wrap: wrap; }
  #tabs button { width: auto; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: center; }
  main { padding: 1rem; }
  .kv { grid-template-columns: 1fr; }
}
