/* ═══════════════════════════════════════════════════════════
   SecureVault — Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:          #0d0d14;
  --surface:     #16161f;
  --surface-2:   #1e1e2e;
  --surface-3:   #262638;
  --border:      #2a2a40;
  --border-dim:  #1f1f32;

  --accent:      #6c63ff;
  --accent-dim:  rgba(108, 99, 255, 0.15);
  --accent-glow: rgba(108, 99, 255, 0.25);
  --teal:        #00d4aa;
  --teal-dim:    rgba(0, 212, 170, 0.12);

  --text:        #e8e8f4;
  --text-dim:    #8888aa;
  --text-faint:  #55556a;

  --success:     #2ed573;
  --warning:     #ffa502;
  --danger:      #ff4757;
  --danger-dim:  rgba(255, 71, 87, 0.15);
  --info:        #54a0ff;

  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.6);

  --transition:  150ms ease;
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono-font { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ─── Auth Pages ────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,99,255,0.12) 0%, transparent 60%), var(--bg);
}

.auth-container { width: 100%; max-width: 400px; padding: 1.5rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.auth-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--danger-dim);
  border: 1px solid rgba(255,71,87,0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.875rem;
}

.form-hint {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}
.form-hint svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; fill: var(--accent); }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.form-group label .required { color: var(--danger); font-size: 0.9em; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.925rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

textarea { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }

.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 2.8rem; }
.toggle-visibility {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  padding: 0.2rem;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.toggle-visibility:hover { color: var(--text); }
.eye-icon { width: 18px; height: 18px; }

/* ─── Strength Bar ──────────────────────────────────────── */
.strength-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}
.strength-bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.3s ease, background-color 0.3s ease;
}
.strength-bar.weak        { background: var(--danger); }
.strength-bar.fair        { background: var(--warning); }
.strength-bar.good        { background: var(--info); }
.strength-bar.strong      { background: var(--teal); }
.strength-bar.very-strong { background: var(--success); }
.strength-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.3rem;
  min-height: 1em;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 0.5rem;
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 0.65rem 1.25rem;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent); }

.btn-danger {
  padding: 0.65rem 1.25rem;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ─── App Layout ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border-dim);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.975rem;
  letter-spacing: -0.01em;
}

/* ─── Search ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  padding: 0.85rem 0.9rem 0.6rem;
  border-bottom: 1px solid var(--border-dim);
}

.search-icon {
  position: absolute;
  left: 1.6rem;
  top: 50%;
  transform: translateY(-40%);
  width: 18px; height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  height: 52px;
  padding: 0 2.8rem 0 2.75rem;
  font-size: 1rem;
  background: var(--surface-2);
  border-color: var(--border);
}
.search-input:focus { border-color: var(--accent); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-hint {
  position: absolute;
  right: 1.6rem;
  top: 50%;
  transform: translateY(-40%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.75rem;
  color: var(--text-faint);
  pointer-events: none;
  font-family: inherit;
}

/* ─── Entry List ─────────────────────────────────────────── */
.list-meta {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  min-height: 1.5rem;
}

.entry-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.entry-list::-webkit-scrollbar { width: 5px; }
.entry-list::-webkit-scrollbar-track { background: transparent; }
.entry-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.entry-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
  animation: slideIn 0.15s ease forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.entry-item:hover { background: var(--surface-2); }
.entry-item.active {
  background: var(--accent-dim);
  border-color: rgba(108, 99, 255, 0.3);
}

.entry-favicon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.entry-favicon img { width: 20px; height: 20px; object-fit: contain; }
.entry-favicon .favicon-fallback {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.entry-info { min-width: 0; flex: 1; }
.entry-domain {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-username {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.entry-category-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-general { background: var(--text-faint); }
.cat-email   { background: var(--info); }
.cat-bank    { background: var(--success); }
.cat-social  { background: var(--accent); }
.cat-work    { background: var(--teal); }
.cat-other   { background: var(--warning); }

.entry-list-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.875rem;
  line-height: 1.8;
}

/* ─── Add Button ─────────────────────────────────────────── */
.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.6rem 0.9rem 0.9rem;
  padding: 0.65rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-add svg { width: 16px; height: 16px; }
.btn-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ─── Detail Panel ───────────────────────────────────────── */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-faint);
  font-size: 0.875rem;
}
.detail-empty svg { width: 72px; height: 72px; opacity: 0.5; }

.detail-content { animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}

.detail-title-area { min-width: 0; flex: 1; }
.detail-domain-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}
.detail-favicon-lg {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-favicon-lg img { width: 24px; height: 24px; object-fit: contain; }
.detail-favicon-lg .favicon-fallback { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.detail-domain {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-domain a { color: var(--text); }
.detail-domain a:hover { color: var(--accent); }
.detail-category {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0.2rem 0.6rem;
  background: var(--surface-3);
  border-radius: 100px;
  margin-top: 0.3rem;
}
.detail-category .dot { width: 5px; height: 5px; border-radius: 50%; }

.detail-actions-top {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Multi-account dropdown */
.account-selector { margin-bottom: 1.5rem; }
.account-selector select { font-weight: 500; }

/* Fields grid */
.detail-fields { display: flex; flex-direction: column; gap: 1rem; }

.detail-field {
  background: var(--surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.detail-field-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
}
.detail-field-value {
  font-size: 0.925rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 26px;
}
.detail-field-value.mono { font-family: 'JetBrains Mono', monospace; }

.field-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.field-actions .btn-icon { width: 28px; height: 28px; }
.field-actions .btn-icon svg { width: 14px; height: 14px; }

/* Password field */
.password-hidden { color: var(--text-faint); letter-spacing: 3px; }
.password-visible { color: var(--teal); }
.password-countdown {
  font-size: 0.75rem;
  color: var(--text-faint);
  min-width: 30px;
  text-align: right;
}

.btn-reveal {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: var(--teal-dim);
  border: 1px solid rgba(0, 212, 170, 0.25);
  border-radius: var(--radius-sm);
  color: var(--teal);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-reveal:hover { background: rgba(0, 212, 170, 0.2); border-color: rgba(0, 212, 170, 0.4); }
.btn-reveal svg { width: 14px; height: 14px; }

@media (max-width: 500px) {
  #pwdField .detail-field-value {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
  #pwdField .field-actions {
    width: 100%;
    justify-content: space-between;
  }
  .btn-reveal {
    flex: 1;
    justify-content: center;
  }
}

.detail-dates {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* Password history */
.history-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-dim);
  padding-top: 1rem;
}
.history-section h4 {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}
.history-list { list-style: none; }
.history-list li {
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-dim);
}
.history-list li:last-child { border-bottom: none; }

/* ─── OTP Timer ──────────────────────────────────────────── */
.otp-desc {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.otp-timer-wrap {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.otp-timer-bar {
  height: 100%;
  background: var(--teal);
  width: 100%;
  border-radius: 2px;
  transition: width 1s linear, background-color 0.5s ease;
}
.otp-timer-bar.warning { background: var(--warning); }
.otp-timer-bar.danger  { background: var(--danger); }

.otp-timer-label {
  font-size: 0.8rem;
  color: var(--text-faint);
  text-align: right;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.otp-input {
  font-size: 1.5rem !important;
  text-align: center;
  letter-spacing: 0.3em;
}

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal.modal-sm { max-width: 400px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.modal-close {
  font-size: 1.25rem;
  line-height: 1;
}
.modal-body { padding: 1.25rem 1.5rem 1.5rem; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Generator options */
.gen-options {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}
.gen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
input[type="range"] { width: 120px; accent-color: var(--accent); }
.gen-checks {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.gen-checks label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ─── Toasts ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow);
  min-width: 260px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastIn 0.2s ease forwards;
  pointer-events: auto;
}
.toast.success { border-color: rgba(46,213,115,0.4); }
.toast.error   { border-color: rgba(255,71,87,0.4); }
.toast.info    { border-color: rgba(84,160,255,0.4); }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
.toast.removing { animation: toastOut 0.2s ease forwards; }

/* ─── Scrollbars ─────────────────────────────────────────── */
.detail-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.detail-panel::-webkit-scrollbar { width: 5px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { width: 100%; }
  .detail-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg);
    padding: 1rem;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  .detail-panel.open {
    transform: translateX(0);
  }
  .detail-header { position: relative; }
  .detail-close-mobile {
    display: flex !important;
  }
}

.detail-close-mobile {
  display: none;
  position: absolute;
  top: 0; left: 0;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0;
}
