/* Opale Vault — Dashboard. CSS pur (pas de @apply : incompatible avec le Tailwind CDN). */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e9e9ec;
  --border-strong: #d8d8dd;
  --text: #18181b;
  --text-soft: #71717a;
  --text-faint: #a1a1aa;
  --accent: #059669;
  --accent-soft: #ecfdf5;
  --accent-border: #a7f3d0;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --red-border: #fecaca;
  --radius: 24px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 12px 48px rgba(24, 24, 27, 0.10);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-shell { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* ── Header ───────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 80px; position: sticky; top: 0; z-index: 40;
  background: rgba(250, 250, 250, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 20px; font-weight: 300; letter-spacing: 0.18em; text-transform: uppercase; }
.brand b { font-weight: 600; color: var(--accent); font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: #f4f4f5; color: var(--text-soft);
}
.badge.online { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Layout ───────────────────────────────────────────────── */
main { padding: 56px 0 80px; }
.hidden { display: none !important; }

.view-head { margin-bottom: 36px; }
.view-head h1 { font-size: 30px; font-weight: 300; letter-spacing: -0.02em; margin: 0; }
.view-head p { color: var(--text-soft); font-size: 14px; margin: 6px 0 0; }

/* ── Tenant bar ───────────────────────────────────────────── */
.tenant-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; flex-wrap: wrap; }
.tenant-pick { display: inline-flex; align-items: center; gap: 10px; }
.tenant-pick span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 600; }
.tenant-pick select {
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--text);
  padding: 9px 36px 9px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.tenant-pick select:focus { border-color: var(--accent); }
.tenant-iso { font-size: 12px; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); padding: 5px 12px; border-radius: 999px; font-weight: 500; }

/* ── Groupes projet / environnement ───────────────────────── */
.proj-group { margin-bottom: 36px; }
.proj-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.proj-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.proj-head .proj-ic { font-size: 15px; }
.env-group { margin: 16px 0 0 0; }
.env-label {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; font-weight: 600; color: var(--text-soft); margin-bottom: 12px;
  padding: 4px 10px; border-radius: 7px; background: #f4f4f5;
}
.env-label.production { background: var(--red-soft); color: var(--red); }
.env-label.staging { background: var(--amber-soft); color: var(--amber); }
.env-label.development { background: #eff6ff; color: #2563eb; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: inline-flex; gap: 4px; background: #f1f1f3; padding: 5px;
  border-radius: 16px; border: 1px solid var(--border); margin-bottom: 44px;
}
.tab {
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 500; color: var(--text-soft);
  padding: 10px 20px; border-radius: 12px; transition: all 0.18s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ── Cards & buttons ──────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.docs-card { padding: 44px; }
.docs-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.docs-card h1 { margin: 0 0 10px; font-size: 34px; font-weight: 300; letter-spacing: -0.03em; }
.docs-card .sub { margin: 0; color: var(--text-soft); line-height: 1.6; }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 32px; }
.doc-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  background: #fafafa;
}
.doc-link:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.doc-link span { color: var(--text-soft); font-size: 14px; line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: all 0.18s; white-space: nowrap;
}
.btn-primary { background: var(--text); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(0.94); }
.btn-ghost { background: #f4f4f5; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: #ececee; color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--text-faint); border-color: transparent; padding: 8px; }
.btn-danger-ghost:hover { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 8px; border-radius: 10px; background: transparent; border-color: transparent; color: var(--text-faint); }
.btn-icon:hover { background: #f4f4f5; color: var(--text); }

/* ── Login ────────────────────────────────────────────────── */
.login-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 440px; padding: 48px 40px; text-align: center; }
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: var(--accent-soft); border: 1px solid var(--accent-border);
}
.login-card h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.login-card .sub { color: var(--text-soft); font-size: 14px; margin: 0 0 32px; }
.login-card .btn { width: 100%; padding: 15px; }

.totp-step { margin-top: 8px; }
.totp-label { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.otp-input {
  width: 100%; text-align: center; font-family: var(--mono); font-size: 26px;
  letter-spacing: 0.45em; padding: 16px 0 16px 0.45em; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fafafa; color: var(--text);
  outline: none; transition: border 0.18s;
}
.otp-input:focus { border-color: var(--accent); background: #fff; }
.muted-link { background: none; border: 0; color: var(--text-faint); font-size: 12px; cursor: pointer; margin-top: 18px; font-family: inherit; }
.muted-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Secrets grid ─────────────────────────────────────────── */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.secret-card { padding: 24px; display: flex; flex-direction: column; gap: 18px; transition: border 0.18s, transform 0.18s; }
.secret-card:hover { border-color: var(--accent-border); }
.secret-card .row { display: flex; align-items: center; justify-content: space-between; }
.type-badge {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 5px 9px; border-radius: 8px; background: #f4f4f5; color: var(--text-soft); font-weight: 600;
}
.type-badge.internal { background: var(--accent-soft); color: var(--accent); }
.secret-card h3 { font-size: 16px; font-weight: 600; margin: 0; }
.secret-card .sid { font-family: var(--mono); font-size: 12px; color: var(--text-faint); margin: 4px 0 0; }
.secret-card .foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-soft); border-top: 1px solid var(--border); padding-top: 16px; }
.rot { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.rot.ok { color: var(--accent); }
.rot.warn { color: var(--amber); }
.rot.expired { color: var(--red); }
.card-actions { display: flex; gap: 4px; }

/* ── Empty / loading states ───────────────────────────────── */
.empty { text-align: center; padding: 72px 24px; }
.empty .ic { font-size: 44px; margin-bottom: 16px; opacity: 0.6; }
.empty h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.empty p { color: var(--text-soft); font-size: 14px; margin: 0 0 24px; }
.skeleton { height: 168px; border-radius: var(--radius); background: linear-gradient(90deg, #f4f4f5 25%, #ececee 50%, #f4f4f5 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Activity feed ────────────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-ic { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; background: #f4f4f5; }
.feed-body { flex: 1; min-width: 0; }
.feed-top { display: flex; align-items: center; gap: 10px; }
.feed-type { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.feed-reason { color: var(--text-soft); font-size: 13px; margin: 3px 0 0; }
.feed-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.decision { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; padding: 3px 8px; border-radius: 7px; }
.decision.allow { background: var(--accent-soft); color: var(--accent); }
.decision.deny { background: var(--red-soft); color: var(--red); }
.decision.info { background: #f1f5f9; color: #475569; }

/* ── Identity ─────────────────────────────────────────────── */
.identity-card { padding: 28px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.identity-card .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 600; }
.identity-card .val { font-family: var(--mono); font-size: 15px; margin-top: 4px; }

/* ── Slide-over ───────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(24, 24, 27, 0.4); backdrop-filter: blur(2px); z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.22s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.slideover {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 92vw; z-index: 70;
  background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column;
}
.slideover.open { transform: translateX(0); }
.slideover header { padding: 28px 28px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.slideover header h2 { font-size: 19px; font-weight: 600; margin: 0; }
.slideover header p { font-size: 13px; color: var(--text-soft); margin: 4px 0 0; }
.slideover .body { padding: 24px 28px; overflow-y: auto; flex: 1; }
.slideover .foot { padding: 18px 28px; border-top: 1px solid var(--border); display: flex; gap: 12px; }
.slideover .foot .btn { flex: 1; }

.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.field input, .field select {
  width: 100%; font-family: inherit; font-size: 14px; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fafafa; color: var(--text); outline: none; transition: border 0.18s;
}
.field input:focus, .field select:focus { border-color: var(--accent); background: #fff; }
.field input.mono { font-family: var(--mono); }

/* ── Modale (QR enrôlement) ───────────────────────────────── */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -48%);
  z-index: 70; width: 360px; max-width: 92vw; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal h2 { font-size: 19px; font-weight: 600; margin: 0 0 6px; }
.modal-sub { font-size: 13px; color: var(--text-soft); margin: 0 0 16px; }
.qr-host { display: flex; justify-content: center; margin: 8px 0 20px; }
.qr-host svg { width: 220px; height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.qr-secret {
  display: inline-block; font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
  background: #f4f4f5; color: var(--text); padding: 8px 12px; border-radius: 8px;
  word-break: break-all; user-select: all;
}

/* ── Toasts ───────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 14px; min-width: 240px; animation: slideIn 0.25s ease;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

footer { border-top: 1px solid var(--border); padding: 28px 0; text-align: center; font-size: 12px; color: var(--text-faint); }

@media (max-width: 540px) {
  .view-head h1 { font-size: 24px; }
  .slideover { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
