/* Painel de gestão do WhatsMcp — app shell no estilo Supabase. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --accent: #00a884;
  --accent-hover: #017e67;
  --accent-soft: #e7f7f2;
  --bg: #fbfbfb;
  --panel: #ffffff;
  --sidebar: #fcfcfc;
  --border: #ededed;
  --border-strong: #e0e0e0;
  --text: #1c1c1c;
  --text-2: #525252;
  --text-3: #8a8a8a;
  --danger: #d6453d;
  --danger-soft: #fdecea;
  --ok: #1fa855;
  --warn: #b88900;
  --warn-soft: #fff4d6;
  --radius: 9px;
  --topbar-h: 50px;
  --sidebar-w: 240px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.04);
  --shadow-pop: 0 10px 30px rgba(0,0,0,.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
svg { display: block; }

/* ---------------- Topbar ---------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .esq { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 16px; height: 16px; fill: #fff; }
.brand .nome { font-weight: 700; font-size: 14px; letter-spacing: -.2px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; min-width: 0; }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .atual { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar .dir { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 9px; border-radius: 8px; cursor: default;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.user-chip .uname { font-size: 13px; color: var(--text-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost {
  font-family: inherit; font-size: 13px; color: var(--text-2);
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; transition: background .12s;
}
.btn-ghost:hover { background: #f4f4f4; }

/* ---------------- Layout corpo ---------------- */
.corpo { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex; flex-direction: column;
}
.sidebar .nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); padding: 10px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.nav-item:hover { background: #f1f1f1; color: var(--text); }
.nav-item.ativo { background: var(--accent-soft); color: var(--accent-hover); }
.nav-item.ativo svg { stroke: var(--accent-hover); }
.sidebar .espaco { flex: 1; }
.voltar {
  display: flex; align-items: center; gap: 8px; color: var(--text-3);
  font-size: 13px; padding: 8px 10px; cursor: pointer; border-radius: 8px;
}
.voltar:hover { background: #f1f1f1; color: var(--text-2); }
.voltar svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------------- Conteúdo ---------------- */
.conteudo { padding: 30px 34px 60px; overflow: auto; }
.container { max-width: 1040px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.page-head .desc { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 15px; border-radius: 8px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,168,132,.25); transition: background .12s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary svg { width: 16px; height: 16px; fill: currentColor; }

/* grid de instâncias */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0; cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .06s;
  overflow: hidden;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card:active { transform: translateY(1px); }
.card .card-top { padding: 16px 16px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card .inst-ident { display: flex; align-items: center; gap: 11px; min-width: 0; }
.card .inst-logo {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: var(--accent-soft); display: grid; place-items: center;
}
.card .inst-logo svg { width: 20px; height: 20px; fill: var(--accent-hover); }
.card .inst-nome { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .inst-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.menu-btn { background: none; border: none; cursor: pointer; padding: 5px; border-radius: 6px; color: var(--text-3); }
.menu-btn:hover { background: #f1f1f1; color: var(--text-2); }
.menu-btn svg { width: 18px; height: 18px; fill: currentColor; }

.card .card-foot {
  border-top: 1px solid var(--border); padding: 11px 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: #fcfcfc;
}

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.desconectado { color: var(--text-3); background: #f0f0f0; }
.badge.desconectado .dot { background: #b5b5b5; }
.badge.conectando { color: var(--warn); background: var(--warn-soft); }
.badge.conectando .dot { background: var(--warn); animation: pulsar 1s infinite; }
.badge.conectado { color: var(--ok); background: #e7f7ee; }
.badge.conectado .dot { background: var(--ok); }
@keyframes pulsar { 50% { opacity: .35; } }

.card-foot .abrir { font-size: 13px; font-weight: 600; color: var(--accent-hover); display: flex; align-items: center; gap: 5px; }
.card-foot .abrir svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

/* estado vazio */
.vazio {
  text-align: center; padding: 70px 20px; background: var(--panel);
  border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--text-3);
}
.vazio .ico { width: 54px; height: 54px; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; margin: 0 auto 16px; }
.vazio .ico svg { width: 28px; height: 28px; fill: var(--accent-hover); }
.vazio h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.vazio p { margin-bottom: 18px; font-size: 13.5px; }

/* cartões de info (view Conta) */
.painel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.painel .ph { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.painel .linha { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.painel .linha:last-child { border-bottom: none; }
.painel .linha .rot { color: var(--text-3); }
.painel .linha .val { color: var(--text); font-weight: 500; }

/* ---------------- Dropdown de menu ---------------- */
.dropdown {
  position: fixed; z-index: 50; min-width: 190px;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-pop); padding: 6px;
  display: none;
}
.dropdown.aberto { display: block; }
.dropdown button {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13.5px; color: var(--text-2);
  padding: 9px 10px; border-radius: 7px; display: flex; align-items: center; gap: 9px;
}
.dropdown button:hover { background: #f4f4f4; color: var(--text); }
.dropdown button.perigo { color: var(--danger); }
.dropdown button.perigo:hover { background: var(--danger-soft); }
.dropdown button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dropdown .sep { height: 1px; background: var(--border); margin: 5px 0; }

/* ---------------- Modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,22,.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.overlay.aberto { display: flex; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 420px; box-shadow: var(--shadow-pop); animation: subir .2s ease both; }
@keyframes subir { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal .mh { padding: 18px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; }
.modal .mb { padding: 20px; }
.modal label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 7px; }
.modal input {
  width: 100%; padding: 11px 13px; font-size: 14px; font-family: inherit;
  border: 1.5px solid var(--border-strong); border-radius: 9px; outline: none; transition: border-color .12s, box-shadow .12s;
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.modal .erro-modal { display: none; color: var(--danger); font-size: 13px; margin-top: 9px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.btn-sec { font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--text-2); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 15px; cursor: pointer; }
.btn-sec:hover { background: #f4f4f4; }
.btn-perigo-solido { font-family: inherit; font-size: 13.5px; font-weight: 600; color: #fff; background: var(--danger); border: none; border-radius: 8px; padding: 9px 15px; cursor: pointer; transition: background .12s; }
.btn-perigo-solido:hover { background: #bf3a33; }
.modal .mb p.confirm-txt { color: var(--text-2); font-size: 14px; line-height: 1.55; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c1c1c; color: #fff; padding: 11px 18px; border-radius: 9px; font-size: 13.5px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 70; }
.toast.visivel { opacity: .96; transform: translateX(-50%) translateY(0); }

/* ---------------- Tela da instância ---------------- */
.inst-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.inst-head .ident { display: flex; align-items: center; gap: 14px; }
.inst-head .ii-logo { width: 46px; height: 46px; border-radius: 11px; background: var(--accent-soft); display: grid; place-items: center; }
.inst-head .ii-logo svg { width: 24px; height: 24px; fill: var(--accent-hover); }
.inst-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; display: flex; align-items: center; gap: 12px; }
.inst-head .ii-sub { color: var(--text-3); font-size: 13px; margin-top: 3px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.info-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.info-card .rot { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.info-card .val { font-size: 15px; font-weight: 600; color: var(--text); }
.info-card .val.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.btn-danger { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); color: var(--danger); border: 1px solid #f0cfcc; font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 15px; border-radius: 8px; cursor: pointer; transition: background .12s; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.key-field { display: flex; align-items: center; gap: 8px; background: #f7f9f8; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; }
.key-field code { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--text-2); letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-field .kbtn { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 9px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.key-field .kbtn:hover { background: #eee; }
.key-field .kbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.painel .pbody { padding: 16px 18px; }
.painel .phelp { color: var(--text-3); font-size: 12.5px; margin: 8px 2px 0; }
.painel .prow { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* ---------------- Responsivo ---------------- */
@media (max-width: 760px) {
  .corpo { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 8px; border-right: none; border-bottom: 1px solid var(--border); gap: 6px; }
  .sidebar .nav-sec, .sidebar .espaco, .sidebar .voltar { display: none; }
  .nav-item { white-space: nowrap; }
  .conteudo { padding: 20px 16px 50px; }
  .user-chip .uname { display: none; }
  .brand .nome { display: none; }
}
