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

:root {
  --bg:      #030712;
  --surface: #111827;
  --card:    #1f2937;
  --border:  #374151;
  --accent:  #3b63ff;
  --accent-h:#1a3ef5;
  --text:    #f9fafb;
  --muted:   #9ca3af;
  --danger:  #ef4444;
  --success: #22c55e;
  --yellow:  #facc15;
  --radius:  10px;
  --font: 'Inter', system-ui, sans-serif;
}

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

input, button, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ── Utilitaires ───────────────────────────────────────── */
.hidden  { display: none !important; }
.w-full  { width: 100%; }
.row     { display: flex; align-items: center; }
.gap     { gap: .75rem; }
.error   { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.success { color: var(--success); font-size: .8rem; margin-top: .25rem; }
.hint    { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* ── Boutons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff; border-radius: var(--radius);
  padding: .6rem 1.2rem; font-weight: 500; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-secondary {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem 1rem; transition: background .15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost { background: none; color: var(--muted); padding: .4rem .6rem; border-radius: 6px; }
.btn-ghost:hover { color: var(--text); background: var(--card); }

.btn-danger { background: rgba(239,68,68,.15); color: var(--danger);
              border-radius: var(--radius); padding: .5rem 1rem; font-size: .8rem; }
.btn-danger:hover { background: rgba(239,68,68,.25); }

/* ── Pages ─────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; }

/* ── Auth ──────────────────────────────────────────────── */
.auth-wrapper { display: flex; align-items: center; justify-content: center;
                flex: 1; padding: 1.5rem; }
.auth-box { width: 100%; max-width: 400px; background: rgba(255,255,255,.04);
            border: 1px solid rgba(255,255,255,.07); border-radius: 16px;
            padding: 2.5rem; backdrop-filter: blur(10px); }
.auth-logo { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-sub { color: var(--muted); margin-bottom: 1.5rem; font-size: .875rem; }

/* ── Formulaires ───────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .9rem; color: var(--text); outline: none; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; font-family: monospace; font-size: .8rem; }
/* Cases à cocher dans un .field : ne pas hériter du style « champ pleine largeur ». */
.field input[type=checkbox] {
  width: auto; background: none; border: none; border-radius: 0; padding: 0; margin: 0;
  accent-color: var(--accent); flex: 0 0 auto; vertical-align: middle;
}

/* Résultat de partage : lien + boîte d'infos clé/valeur */
.share-url-row { display: flex; gap: .5rem; align-items: stretch; }
.share-url-row input { flex: 1; min-width: 0; font-family: monospace; font-size: .8rem; }
.share-url-row .btn-secondary { white-space: nowrap; flex: 0 0 auto; }
.kv-box { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .25rem .9rem; }
.kv-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
          padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.kv-row:last-child { border-bottom: none; }
.kv-k { color: var(--muted); }
.kv-v { font-weight: 600; text-align: right; word-break: break-word; }

.form-stack { display: flex; flex-direction: column; gap: .75rem; }
.form-stack input { background: var(--card); border: 1px solid var(--border);
                    border-radius: 8px; padding: .6rem .9rem; color: var(--text);
                    outline: none; width: 100%; transition: border .15s; }
.form-stack input:focus { border-color: var(--accent); }

/* ── TOTP Timer ────────────────────────────────────────── */
.totp-timer { display: flex; align-items: center; justify-content: center;
              gap: .75rem; margin-bottom: 1.25rem; }
.timer-ring  { width: 48px; height: 48px; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: var(--card); stroke-width: 3; }
.timer-progress { fill: none; stroke: var(--accent); stroke-width: 3;
                  stroke-dasharray: 94.2; transition: stroke-dashoffset 1s linear, stroke .3s; }
#timer-count { position: absolute; font-size: .75rem; font-weight: 700; }
.totp-timer { position: relative; width: 48px; height: 48px; }
.code-input { background: var(--card); border: 1px solid var(--border); border-radius: 8px;
              padding: .75rem; color: var(--text); font-size: 1.5rem; letter-spacing: .4em;
              text-align: center; width: 100%; outline: none; margin-bottom: .75rem; }
.code-input:focus { border-color: var(--accent); }

/* ── Layout Dashboard ──────────────────────────────────── */
#page-dashboard { flex-direction: row; }

.sidebar { width: 220px; min-width: 220px; background: var(--surface);
           border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem; }
.sidebar-logo { display: flex; align-items: center; gap: .6rem; padding: .5rem .4rem 1.2rem;
                font-weight: 700; font-size: .95rem; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: .75rem;
                  display: flex; flex-direction: column; gap: .2rem; margin-top: .75rem; }

.nav-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem;
            border-radius: 8px; color: var(--muted); font-size: .85rem; width: 100%;
            text-align: left; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.danger:hover { color: var(--danger); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem;
          background: var(--surface); border-bottom: 1px solid var(--border); }
.search-box { flex: 1; background: var(--card); border: 1px solid var(--border);
              border-radius: 8px; padding: .5rem .9rem; color: var(--text); outline: none; transition: border .15s; }
.search-box:focus { border-color: var(--accent); }

.item-list { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem;
             display: flex; flex-direction: column; gap: .5rem; }

/* ── Item row ──────────────────────────────────────────── */
.item-row { display: flex; align-items: center; gap: .9rem; background: var(--card);
            border-radius: 10px; padding: .75rem 1rem; cursor: pointer; transition: background .12s; }
.item-row:hover { background: var(--border); }
.item-icon { font-size: 1.4rem; line-height: 1; }
.item-info { flex: 1; min-width: 0; }
.item-label { font-weight: 500; color: var(--text); white-space: nowrap;
              overflow: hidden; text-overflow: ellipsis; }
.item-meta  { font-size: .75rem; color: var(--muted); }
.item-fav   { background: none; border: none; font-size: 1rem; padding: .25rem;
              border-radius: 4px; color: var(--border); cursor: pointer; transition: color .12s; }
.item-fav.on { color: var(--yellow); }
.item-fav:hover { color: var(--yellow); }
.item-arrow { color: var(--muted); font-size: .8rem; }

.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65);
                 display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px;
         max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
                padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { color: var(--muted); font-size: 1.1rem; padding: .25rem .5rem;
               border-radius: 6px; transition: color .12s; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }

.modal-footer { display: flex; align-items: center; gap: .75rem;
                padding-top: 1.25rem; margin-top: .5rem; border-top: 1px solid var(--border); }
.modal-footer .spacer { flex: 1; }

/* ── Champ password avec reveal ────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.5rem; }
.pw-actions { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
              display: flex; gap: .2rem; }
.pw-actions button { padding: .3rem .35rem; border-radius: 5px; font-size: .75rem;
                     color: var(--muted); transition: color .12s, background .12s; }
.pw-actions button:hover { color: var(--text); background: var(--border); }

/* ── Générateur ────────────────────────────────────────── */
.generator-box { background: var(--card); border-radius: 10px; padding: 1rem; margin-top: .75rem; }
.generator-box h4 { font-size: .85rem; font-weight: 600; margin-bottom: .75rem; }
.gen-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.gen-slider { flex: 1; accent-color: var(--accent); }
.gen-options { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-bottom: .75rem; }
.gen-options label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); cursor: pointer; }
.gen-options input[type=checkbox] { accent-color: var(--accent); }
.gen-result { background: var(--bg); border-radius: 8px; padding: .6rem .9rem;
              font-family: monospace; font-size: .85rem; word-break: break-all;
              display: flex; align-items: center; gap: .5rem; }
.gen-result span { flex: 1; }
.strength-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: .5rem; overflow: hidden; }
.strength-fill { height: 100%; border-radius: 2px; transition: width .3s, background .3s; }

/* ── Settings ──────────────────────────────────────────── */
#page-settings { flex-direction: column; }
.settings-wrapper { max-width: 640px; margin: 0 auto; padding: 1.5rem; width: 100%; }
.settings-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.settings-header h2 { font-size: 1.1rem; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: 12px; padding: 1.5rem; margin-bottom: 1rem; }
.card h3 { font-weight: 600; margin-bottom: .5rem; }

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