/* =========================================================
   Passcore — estilos
   Tema via [data-theme="dark"|"light"] no <html>.
   Paleta: neutros frios (slate) + acento índigo. Display em
   Space Grotesk, corpo em Inter.
   ========================================================= */

:root {
  /* Acento (igual nos dois temas, com leve ajuste no escuro) */
  --primary: #5b6cff;
  --primary-hover: #4656e6;
  --primary-soft: rgba(91, 108, 255, 0.12);

  /* Tema claro (padrão de fallback) */
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --text: #16181d;
  --text-muted: #5c6373;
  --border: #e3e6ee;
  --shadow: 0 1px 2px rgba(16, 18, 30, .04), 0 8px 24px rgba(16, 18, 30, .06);
  --danger: #e5484d;
  --success: #2faa6a;

  --radius: 14px;
  --radius-sm: 10px;
  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font-body);
}

[data-theme="dark"] {
  --primary: #6f7dff;
  --primary-hover: #8290ff;
  --primary-soft: rgba(111, 125, 255, 0.16);

  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1f232c;
  --text: #eef0f4;
  --text-muted: #9aa1b1;
  --border: #272b35;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  --danger: #ff6369;
  --success: #46c787;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.hidden { display: none !important; }

/* -------------------- Barra superior -------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

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

/* Ícone de tema: mostra sol no escuro (pra clarear) e lua no claro */
.theme-icon { display: none; }
[data-theme="dark"] .theme-icon--sun { display: block; }
[data-theme="light"] .theme-icon--moon { display: block; }

/* -------------------- Botões -------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }

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

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }

/* -------------------- Tela de autenticação -------------------- */
.auth {
  min-height: calc(100vh - 65px);
  display: grid;
  place-items: center;
  padding: 32px 18px;
}
.auth__card {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.auth__hero {
  padding: 44px 40px;
  background:
    radial-gradient(120% 120% at 0% 0%, var(--primary-soft), transparent 60%),
    var(--surface-2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
.auth__badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 11px;
  border-radius: 999px;
}
.auth__title {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 4px 0 0;
}
.auth__title span { color: var(--primary); }
.auth__subtitle { color: var(--text-muted); margin: 0; max-width: 34ch; }

.auth__form { padding: 40px; display: flex; flex-direction: column; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* -------------------- Campos de formulário -------------------- */
.field { display: block; margin-bottom: 16px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field__hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.field__password { position: relative; display: flex; gap: 6px; }
.field__password input { flex: 1; }
.reveal {
  flex: 0 0 auto;
  width: 42px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
}
.reveal:hover { color: var(--text); }

.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 10px; }

/* Medidor de força */
.strength {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}
.strength span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width .25s ease, background .25s ease;
}

/* -------------------- Cofre / toolbar -------------------- */
.vault { max-width: 1000px; margin: 0 auto; padding: 24px 18px 60px; }
.vault__toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.search {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text-muted);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text);
  padding: 11px 0;
}
.search input:focus { outline: none; }

.vault__buttons { display: flex; gap: 8px; position: relative; }

.menu { position: relative; }
.menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 230px;
  padding: 6px;
  z-index: 30;
}
.menu__list button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
}
.menu__list button:hover { background: var(--surface-2); }

/* -------------------- Cards de senha -------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, transform .08s;
}
.card:hover { border-color: var(--primary); }
.card__head { display: flex; align-items: center; gap: 12px; }
.card__avatar {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
}
.card__title { font-weight: 600; line-height: 1.2; word-break: break-word; }
.card__sub { font-size: 12.5px; color: var(--text-muted); word-break: break-all; }

.card__row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
}
.card__row code { font-family: var(--font-body); letter-spacing: .12em; flex: 1; }
.card__mini {
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 2px 4px; border-radius: 6px;
}
.card__mini:hover { color: var(--text); background: var(--surface); }

.card__actions { display: flex; gap: 8px; margin-top: 2px; }
.card__actions button {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 9px; padding: 7px; cursor: pointer;
}
.card__actions button:hover { background: var(--surface-2); }
.card__actions .is-danger:hover { color: var(--danger); border-color: var(--danger); }

/* -------------------- Estado vazio -------------------- */
.empty { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty__art {
  width: 76px; height: 76px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 20px; color: var(--primary);
  background: var(--primary-soft);
}
.empty h2 { font-family: var(--font-display); color: var(--text); margin: 0 0 6px; }

/* -------------------- Modal -------------------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(8, 10, 16, .55); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h2 { font-family: var(--font-display); margin: 0; font-size: 19px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* -------------------- Toast -------------------- */
.toast {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 60;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* -------------------- Derivador de senhas -------------------- */
.derive-intro { color: var(--text-muted); font-size: 13.5px; margin: 0 0 16px; }
.derive-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.derive-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.derive-item code {
  flex: 1; font-family: var(--font-body);
  font-size: 14px; word-break: break-all; letter-spacing: .02em;
}
.derive-strength {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 999px;
}

/* -------------------- Rodapé -------------------- */
.site-footer {
  text-align: center;
  padding: 22px 18px 28px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

/* -------------------- Boas-vindas -------------------- */
.welcome {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--primary-soft), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.welcome__text h2 { font-family: var(--font-display); margin: 0 0 2px; font-size: 20px; }
.welcome__text p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* -------------------- Barra de grupos (chips) -------------------- */
.group-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.group-bar:empty { display: none; }
.chip {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); border-radius: 999px;
  padding: 6px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface-2); }
.chip span { font-size: 11px; background: var(--surface-2); color: var(--text-muted); border-radius: 999px; padding: 1px 7px; }
.chip.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.is-active span { background: rgba(255,255,255,.25); color: #fff; }

.card__group {
  margin-left: auto; align-self: flex-start;
  font-size: 11px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.no-results { color: var(--text-muted); text-align: center; padding: 40px 0; }

/* -------------------- Segmentos (níveis do derivador) -------------------- */
.seg-group { margin-bottom: 14px; }
.seg-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.seg-label small { font-weight: 400; opacity: .8; }
.segmented {
  display: flex; gap: 4px;
  background: var(--surface-2); padding: 4px; border-radius: 11px;
}
.segmented button {
  flex: 1; border: 0; background: transparent;
  font: inherit; font-weight: 600; font-size: 13px;
  color: var(--text-muted); padding: 8px; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* -------------------- Responsivo -------------------- */
@media (max-width: 760px) {
  .auth__card { grid-template-columns: 1fr; max-width: 440px; }
  .auth__hero { padding: 32px 28px 8px; }
  .auth__form { padding: 28px; }
  .auth__title { font-size: 28px; }
}

/* Acessibilidade: foco visível e respeito a movimento reduzido */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================
   Passcore — UI adicionada (perfil, grupos, visualizações)
   ========================================================= */

/* ---- Avatar ---- */
.avatar {
  display: grid; place-items: center;
  border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff; font-family: var(--font-display); font-weight: 700;
  background-size: cover; background-position: center;
}
.avatar--sm { width: 30px; height: 30px; font-size: 13px; }
.avatar--lg { width: 84px; height: 84px; font-size: 30px; }

.avatar-btn {
  border: 1px solid var(--border); background: transparent;
  padding: 3px; border-radius: 50%; cursor: pointer; line-height: 0;
}
.avatar-btn:hover { background: var(--surface-2); }

#profileMenu { min-width: 210px; }
#profileMenu button { font-size: 14px; }

/* ---- Seletor de visualização ---- */
.view-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.view-count { color: var(--text-muted); font-size: 13px; }
.view-switch { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.view-switch button {
  display: grid; place-items: center; width: 34px; height: 30px;
  border: 0; background: transparent; color: var(--text-muted);
  border-radius: 7px; cursor: pointer; transition: background .15s, color .15s;
}
.view-switch button:hover { color: var(--text); }
.view-switch button.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ---- Nota nos cards ---- */
.card__note, .row__note {
  font-size: 12.5px; color: var(--text-muted);
  background: var(--surface-2); border-radius: 8px;
  padding: 7px 10px; white-space: pre-wrap; word-break: break-word;
}
.card__note::before, .row__note::before { content: "📝 "; }

/* ---- Visualização LISTA ---- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.rowi {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.rowi:hover { border-color: var(--primary); }
.rowi__main { min-width: 0; }
.rowi__title { font-weight: 600; }
.rowi__sub { font-size: 12.5px; color: var(--text-muted); word-break: break-all; }
.rowi__pw { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; }
.rowi__pw code { letter-spacing: .1em; }
.rowi__actions { display: flex; gap: 6px; align-items: center; }
.rowi__extra { grid-column: 1 / -1; }

/* ---- Visualização TABELA ---- */
.tablewrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}
.ptable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ptable th, .ptable td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.ptable th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); }
.ptable tr:last-child td { border-bottom: 0; }
.ptable code { letter-spacing: .1em; }
.ptable .mini-row { display: flex; gap: 6px; align-items: center; }
.ptable .nowrap { white-space: nowrap; }

/* ---- Derivador embutido ---- */
.inline-derive {
  margin-top: 12px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.inline-derive__head { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.inline-derive .derive-item { background: var(--surface); }
.inline-derive .derive-item code { cursor: pointer; }

/* ---- Perfil ---- */
.profile-top { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.profile-avatar { position: relative; }
.avatar-edit {
  position: absolute; right: -2px; bottom: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--primary); color: #fff;
  cursor: pointer; font-size: 13px; display: grid; place-items: center;
}
.profile-meta__email { font-weight: 600; word-break: break-all; }
.profile-meta__since { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.link-btn { background: none; border: 0; color: var(--danger); font: inherit; font-size: 12.5px; cursor: pointer; padding: 4px 0; margin-top: 4px; }
.link-btn:hover { text-decoration: underline; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Gerenciar grupos ---- */
.groups-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.group-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
}
.group-item input {
  flex: 1; border: 1px solid transparent; background: transparent;
  font: inherit; color: var(--text); border-radius: 7px; padding: 6px 8px;
}
.group-item input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.group-item .count { font-size: 12px; color: var(--text-muted); }
.group-item button {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 7px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600;
}
.group-item .is-danger:hover { color: var(--danger); border-color: var(--danger); }
.groups-list:empty::after { content: "Nenhum grupo ainda."; color: var(--text-muted); font-size: 13.5px; }
