/* =============================================
   GESTOR PASS — EXTENSION DESIGN SYSTEM
   Aligned with main web Obsidian Vault theme
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-sans: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg-base: #07090F;
  --bg-surface: #0D1117;
  --bg-elevated: #161B26;
  --bg-hover: #1C2333;
  --bg-input: rgba(13, 17, 23, 0.92);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #07090F;

  --border-subtle: rgba(148, 163, 184, 0.10);
  --border-default: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.30);

  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --accent-muted: rgba(45, 212, 191, 0.12);
  --accent-alt: #FBBF24;
  --focus-ring: rgba(45, 212, 191, 0.30);

  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;

  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body { min-height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(45, 212, 191, 0.06), transparent 50%),
    radial-gradient(ellipse at 90% 5%, rgba(251, 191, 36, 0.04), transparent 40%);
}

body.popup-page { width: min(360px, 100vw); }
body.options-page, body.success-page { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: rgba(45, 212, 191, 0.20); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

/* =============================================
   SHELLS & CONTAINERS
   ============================================= */
.extension-shell, .success-shell { padding: 16px; }
.options-shell { max-width: 860px; margin: 0 auto; padding: 32px 24px; }

.extension-panel, .success-card {
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

/* =============================================
   HEADERS & BRANDING
   ============================================= */
.panel-header, .hero-header {
  display: grid;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-block { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.12), rgba(20, 184, 166, 0.06));
  border: 1px solid rgba(45, 212, 191, 0.12);
  color: var(--accent);
}

.brand-copy { display: grid; gap: 1px; }
.eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-alt);
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
.hero-copy, .hero-subtitle { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.section-copy { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

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

/* =============================================
   PANEL BODY & SECTIONS
   ============================================= */
.panel-body, .flat-popup-body { display: grid; }
.panel-body > * + *, .flat-popup-body > * + * { border-top: 1px solid var(--border-subtle); }

.popup-strip, .popup-strip-status, .popup-strip-suggestions, .popup-strip-identities {
  padding: 14px 18px;
  display: grid;
  gap: 10px;
}

.popup-strip-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

/* =============================================
   STATUS & METRICS
   ============================================= */
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: rgba(45, 212, 191, 0.12);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.15);
}
.status-pill[data-tone="error"] { background: rgba(239, 68, 68, 0.12); color: #F87171; border-color: rgba(239, 68, 68, 0.15); }
.status-pill[data-tone="ok"] { background: rgba(16, 185, 129, 0.12); color: #34D399; border-color: rgba(16, 185, 129, 0.15); }

.meta-grid, .popup-meta-grid { display: grid; gap: 6px; }
.meta-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meta-key { font-size: 0.72rem; color: var(--text-muted); }
.meta, .meta-value { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; text-align: right; }

.metric-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.metric-value { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }

.metric-grid, .popup-inline-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-card, .popup-inline-metric {
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: 4px;
}
.popup-inline-metric:first-child { border-color: rgba(45, 212, 191, 0.12); }

/* =============================================
   SUGGESTIONS
   ============================================= */
.suggestion-list, .popup-suggestion-list { list-style: none; display: grid; gap: 4px; }

.suggestion-item {
  display: grid;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.suggestion-item:hover { border-color: var(--accent); background: var(--accent-muted); }
.suggestion-item.expanded {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.08);
}

.suggestion-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.suggestion-top strong { font-size: 0.82rem; color: var(--text-primary); }
.suggestion-rank { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }
.suggestion-copy-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.suggestion-item.expanded .suggestion-copy-hint {
  color: var(--accent-hover);
}

.suggestion-actions {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.suggestion-item.expanded .suggestion-actions {
  display: flex;
}

.suggestion-copy-btn {
  padding: 0.42rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.74rem;
  line-height: 1;
}
.suggestion-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.suggestion-copy-btn.copied {
  border-color: #34d399;
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}
.suggestion-copy-btn.error {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.empty-state-item { padding: 16px; text-align: center; font-size: 0.82rem; color: var(--text-muted); }

/* =============================================
   TOTP in suggestions
   ============================================= */
.suggestion-totp {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.suggestion-totp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.suggestion-totp-code {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
}

.suggestion-totp-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-alt);
}

.suggestion-totp-bar {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  margin-top: 6px;
}

.suggestion-totp-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #14b8a6);
  transition: width 200ms linear;
}

.suggestion-totp-meta {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.mono {
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
}

/* =============================================
   BUTTONS
   ============================================= */
button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  transition: all var(--transition-base);
}

.btn-primary {
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
  background: linear-gradient(135deg, var(--accent), #14B8A6);
  color: var(--text-inverse);
  border: 1px solid rgba(45, 212, 191, 0.5);
  border-radius: var(--radius-full);
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.15);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent)); box-shadow: 0 0 24px rgba(45, 212, 191, 0.25); }

.btn-secondary {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-full { width: 100%; }
button:disabled { opacity: 0.45; pointer-events: none; }

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
button.loading .spinner { display: block; }
button.loading span { opacity: 0.6; }

.action-row { display: flex; gap: 8px; }

/* =============================================
   OPTIONS PAGE
   ============================================= */
.options-hero, .flat-options-hero {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: clamp(24px, 3vw, 36px);
  margin-bottom: 24px;
}

.options-grid, .flat-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.options-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.options-panel h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text-primary);
}

.options-stack { display: grid; gap: 20px; }
.options-stack > * + * { /* No separator needed; gap handles spacing */ }

.section-stack { display: grid; gap: 16px; }
.section-card h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* =============================================
   FORMS
   ============================================= */
.form-group { display: grid; gap: 6px; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}
.input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

.input-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted); }

input[type="text"], input[type="url"], input[type="email"],
input[type="password"], input[type="number"] {
  width: 100%;
  padding: 0.6rem 0;
  font-size: 0.85rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
}
input::placeholder { color: var(--text-muted); }

.input-wrapper input { border: none; background: transparent; padding: 0.6rem 0; }
.input-wrapper input:focus { box-shadow: none; outline: none; }

.otp-input {
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  letter-spacing: 0.4em;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.otp-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); outline: none; }

/* =============================================
   TOGGLES
   ============================================= */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.toggle-group:last-child { border-bottom: none; }

.toggle-label { flex: 1; }
.toggle-title { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); display: block; }
.toggle-desc { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 2px; }

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  transition: all var(--transition-base);
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-base);
}
.switch input:checked + .slider { background: var(--accent-muted); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--accent); }

/* =============================================
   SUCCESS PAGE
   ============================================= */
.success-card { text-align: center; padding: clamp(32px, 5vw, 48px); }
.flat-success-card { text-align: center; }
.success-card h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.success-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; }

.success-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

/* =============================================
   TOASTS
   ============================================= */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: grid;
  gap: 8px;
  max-width: 340px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  animation: toastIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.success .toast-icon { color: #34D399; }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }
.toast.error .toast-icon { color: #F87171; }
.toast.info { border-color: rgba(45, 212, 191, 0.3); }
.toast.info .toast-icon { color: var(--accent); }
.toast-icon { display: flex; flex-shrink: 0; }

/* =============================================
   2FA SECTION
   ============================================= */
#twoFactorSection { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .options-grid, .flat-options-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .extension-shell, .success-shell { padding: 12px; }
  .options-shell { padding: 16px; }
  .panel-header, .hero-header { padding: 14px; }
  .popup-strip { padding: 12px 14px; }
  .popup-inline-metrics { grid-template-columns: 1fr; }
  .brand-row { flex-wrap: wrap; }
  .success-card { padding: 24px; }
}

@media (max-width: 560px) {
  body.popup-page { width: 100vw; }
  .metric-grid { grid-template-columns: 1fr; }
  .status-line { flex-direction: column; align-items: flex-start; gap: 4px; }
  .meta-row { flex-direction: column; align-items: flex-start; }
  .meta-value { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
