/* PrivateVault — Styles
   Design intent: matte black vault, cool slate accents, surgical UI.
   Every element earns its place. Nothing decorative.
*/

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg-void:     #0d0d0f;
  --bg-base:     #111217;
  --bg-surface:  #18191f;
  --bg-elevated: #1f2028;
  --bg-hover:    #252730;

  --border:      #2a2c36;
  --border-dim:  #1f2028;

  --txt-primary:   #e8e9ef;
  --txt-secondary: #8a8d9f;
  --txt-muted:     #55586a;

  --accent:        #5b8af0;       /* cool blue — readable on dark, not garish */
  --accent-dim:    rgba(91,138,240,0.15);
  --accent-hover:  #7aa0f4;

  --danger:        #e05c5c;
  --danger-dim:    rgba(224,92,92,0.15);

  --success:       #4caf7d;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  14px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --shadow-card: 0 1px 3px rgba(0,0,0,.45), 0 4px 16px rgba(0,0,0,.3);
  --shadow-modal: 0 8px 48px rgba(0,0,0,.7);
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-void);
  color: var(--txt-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ─── App root ────────────────────────────────────────────────────────────── */
#app { min-height: 100dvh; }

/* ─── Auth / Setup views ─────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(91,138,240,.06) 0%, transparent 70%),
    var(--bg-void);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-modal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.brand h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.4px;
  color: var(--txt-primary);
}
.lock-icon {
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}
.auth-sub {
  color: var(--txt-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ─── Form elements ──────────────────────────────────────────────────────── */
.field-group {
  margin-bottom: 18px;
}
.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-secondary);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.field-group.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.field-group.row label { margin-bottom: 0; min-width: 52px; }
.field-group.full-width { grid-column: 1 / -1; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input::placeholder { color: var(--txt-muted); }
select option { background: var(--bg-elevated); }
textarea { resize: vertical; min-height: 72px; }

.pw-field-wrap {
  position: relative;
  display: flex;
}
.pw-field-wrap input { padding-right: 40px; }
.eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--txt-muted);
  padding: 4px;
  line-height: 1;
}

.pw-strength {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
  min-height: 16px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  margin-top: 8px;
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary-sm {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary-sm:hover { background: var(--accent-hover); }

.btn-secondary {
  width: 100%;
  padding: 11px;
  background: var(--bg-elevated);
  color: var(--txt-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  width: 100%;
  padding: 11px;
  background: none;
  color: var(--txt-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.btn-ghost:hover { color: var(--txt-primary); border-color: var(--txt-muted); }

.btn-ghost-sm {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-secondary);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.btn-ghost-sm:hover { color: var(--txt-primary); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--txt-muted);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.1s;
}
.icon-btn:hover    { color: var(--txt-primary); background: var(--bg-hover); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-dim); }

.passkey-divider {
  text-align: center;
  color: var(--txt-muted);
  font-size: 12px;
  margin: 16px 0 4px;
}

/* ─── Warning / error / success ──────────────────────────────────────────── */
.warning-box {
  background: rgba(240,180,40,.08);
  border: 1px solid rgba(240,180,40,.2);
  border-radius: var(--radius-sm);
  color: #c9a535;
  font-size: 12px;
  padding: 10px 12px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
}
.success-msg {
  color: var(--success);
  font-size: 13px;
  margin-top: 10px;
}

/* ─── Vault layout ───────────────────────────────────────────────────────── */
.vault-layout {
  display: flex;
  min-height: 100dvh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-base);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.brand-small {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-secondary);
  padding: 0 16px;
  margin-bottom: 20px;
  letter-spacing: .02em;
}
.lock-icon-sm { color: var(--accent); }

.cat-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--txt-secondary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}
.cat-btn:hover { background: var(--bg-hover); color: var(--txt-primary); }
.cat-btn.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-footer {
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-dim);
  margin-top: 16px;
  padding-top: 12px;
}

/* Main content */
.vault-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.vault-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-dim);
  background: var(--bg-base);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-wrap { flex: 1; }
.search-wrap input {
  background: var(--bg-elevated);
  border-color: var(--border-dim);
  border-radius: 20px;
  padding: 8px 16px;
}

/* ─── Entry grid ─────────────────────────────────────────────────────────── */
.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  padding: 20px;
  align-content: start;
}

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  color: var(--txt-muted);
  font-size: 14px;
  padding: 60px 20px;
}

.entry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}
.entry-card:hover { border-color: var(--border); }

.entry-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.entry-favicon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.entry-meta { flex: 1; min-width: 0; }
.entry-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--txt-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-username {
  font-size: 12px;
  color: var(--txt-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-actions-top {
  display: flex;
  gap: 2px;
}

.entry-pw-row, .entry-totp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.pw-mask {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--txt-secondary);
  letter-spacing: 2px;
  user-select: none;
}
.totp-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
}

.btn-copy {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-copy:hover { color: var(--txt-primary); background: var(--bg-hover); }

.entry-url a {
  font-size: 11px;
  color: var(--txt-muted);
  text-decoration: none;
}
.entry-url a:hover { color: var(--accent); text-decoration: underline; }

/* ─── Modal / Overlay ────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal-card.modal-wide { max-width: 640px; }
.modal-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--txt-primary);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.modal-actions .btn-primary,
.modal-actions .btn-ghost { margin-top: 0; }

/* ─── Password generator ─────────────────────────────────────────────────── */
.gen-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--txt-secondary);
  cursor: pointer;
  user-select: none;
}
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.gen-output-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gen-output {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--bg-elevated);
  border-color: var(--border);
  letter-spacing: .5px;
}

/* ─── Settings ───────────────────────────────────────────────────────────── */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-dim);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-secondary);
  margin-bottom: 12px;
  letter-spacing: .04em;
}
.setting-note {
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 8px;
  line-height: 1.5;
}
.danger-zone h4 { color: var(--danger); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--txt-primary);
  font-size: 13px;
  padding: 10px 20px;
  z-index: 9999;
  box-shadow: var(--shadow-modal);
  animation: toast-in .2s ease;
  white-space: nowrap;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Splash ─────────────────────────────────────────────────────────────── */
.splash {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  color: var(--txt-muted);
  font-size: 14px;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .vault-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    position: relative;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border-dim);
  }
  .brand-small { display: none; }
  .cat-nav {
    flex-direction: row;
    gap: 4px;
    padding: 0;
    overflow-x: auto;
  }
  .cat-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 10px;
  }
  .sidebar-footer {
    display: none;
  }
  .entries-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .modal-grid {
    grid-template-columns: 1fr;
  }
  .modal-card { padding: 20px 16px; }
  .auth-card  { padding: 24px 20px; }

  /* iOS safe area */
  .vault-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .toast {
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
  }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Focus ring (accessibility) ─────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
