/* ==========================================================================
   PassGear — style.css
   Palette : graphite / encre profonde, accent cyan-signal (évoque le
   chiffrement / le verrou), police utilitaire monospace pour les secrets.
   ========================================================================== */

:root {
  --font-display: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 12px 40px -12px rgba(10, 14, 25, 0.35);

  --accent: #2fd4c9;
  --accent-strong: #16b8ac;
  --accent-soft: rgba(47, 212, 201, 0.14);

  --danger: #e5546b;
  --danger-soft: rgba(229, 84, 107, 0.14);
  --warning: #e0a94f;
  --warning-soft: rgba(224, 169, 79, 0.16);
  --info: #5b9de0;
  --info-soft: rgba(91, 157, 224, 0.14);
}

/* ---- Thème clair (par défaut) ---- */
:root,
[data-theme="light"] {
  --bg: #f2f4f7;
  --bg-elevated: #ffffff;
  --bg-inset: #eaedf2;
  --border: #dde2ea;
  --text: #1b2430;
  --text-muted: #5c6878;
  --text-faint: #8b96a5;
}

/* ---- Thème sombre ---- */
[data-theme="dark"] {
  --bg: #10141c;
  --bg-elevated: #171d28;
  --bg-inset: #1e2531;
  --border: #2a3241;
  --text: #e7ebf1;
  --text-muted: #9aa5b5;
  --text-faint: #6c7686;
}

/* ---- Auto : suit la préférence système ---- */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #10141c;
    --bg-elevated: #171d28;
    --bg-inset: #1e2531;
    --border: #2a3241;
    --text: #e7ebf1;
    --text-muted: #9aa5b5;
    --text-faint: #6c7686;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }

a { color: var(--accent-strong); }

/* ---- Écrans plein cadre ---- */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#screen-vault.screen {
  display: block;
  align-items: initial;
  justify-content: initial;
  padding: 0;
}

/* ---- Carte d'authentification ---- */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-mark {
  font-size: 28px;
  color: var(--accent);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.brand-compact .brand-title { font-size: 17px; }
.brand-compact .brand-mark { font-size: 20px; }

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Champs de formulaire ---- */
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 4px;
}

.field-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-textarea { resize: vertical; min-height: 70px; }

.hint {
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 10px 0;
}

/* ---- Boutons ---- */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.12s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-block { width: 100%; margin-top: 16px; }

.btn-primary {
  background: var(--accent);
  color: #06231f;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-secondary {
  background: var(--bg-inset);
  color: var(--text);
  border-color: var(--border);
  margin-top: 8px;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

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

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
  margin-top: 8px;
}

.btn-icon { padding: 8px 10px; }

.file-btn { display: block; text-align: center; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Zone sensible (details/summary) ---- */
.danger-zone {
  margin-top: 20px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.danger-zone summary {
  cursor: pointer;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* ---- Bannières de message ---- */
.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 10px 0;
  border: 1px solid transparent;
}
.banner-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.banner-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.banner-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }

/* ---- Barre supérieure (coffre) ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-wrap { flex: 1; max-width: 520px; }
.search-input { padding: 9px 14px; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* ---- Layout principal ---- */
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 { font-size: 15px; color: var(--text-muted); margin: 0; }

.settings-group {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.settings-group:last-child { border-bottom: none; margin-bottom: 0; }
.settings-group h3 { font-size: 14px; margin: 0 0 8px; }

/* ---- Liste d'entrées ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.entry-avatar {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}

.entry-main { flex: 1; min-width: 0; }
.entry-service { font-size: 14.5px; margin: 0; font-weight: 600; }
.entry-username {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-meta { font-size: 11.5px; color: var(--text-faint); margin: 4px 0 0; }

.entry-actions { display: flex; gap: 4px; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { background: var(--bg); border-color: var(--border); }
.icon-btn-danger:hover { background: var(--danger-soft); }

/* ---- Modale ---- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 25, 0.55);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
}
.modal-content h2 { margin-top: 0; font-size: 18px; }

.entry-form { display: flex; flex-direction: column; }
.password-row { display: flex; gap: 8px; }
.password-row .field-input { font-family: var(--font-mono); }

.strength-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.strength-meter {
  display: flex;
  gap: 4px;
  flex: 1;
}
.strength-meter span {
  height: 4px;
  flex: 1;
  background: var(--bg-inset);
  border-radius: 2px;
}
.strength-meter[data-score="1"] span:nth-child(1) { background: var(--danger); }
.strength-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.strength-meter[data-score="3"] span:nth-child(-n+3) { background: var(--accent); }
.strength-meter[data-score="4"] span { background: var(--accent-strong); }
.strength-label { font-size: 12px; color: var(--text-muted); min-width: 70px; text-align: right; }

.generator-box {
  margin: 14px 0;
  padding: 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.generator-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.generator-row input[type="range"] { flex: 1; margin-left: 12px; }
.generator-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-error { border-color: var(--danger); color: var(--danger); }

.sync-status-line { margin-top: 10px; }
.sync-status-line.sync-status-error { color: var(--danger); }

/* ---- Focus visible global (accessibilité) ---- */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Réduction de mouvement ---- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .entry-card { flex-wrap: wrap; }
  .entry-actions { width: 100%; justify-content: flex-end; }
}
