/* n8n Vault — visual language borrowed from the n8n editor: light, quiet
   surfaces, a single warm accent, generous whitespace. */

:root {
  --accent: #ff6d5a;
  --accent-dark: #f4573f;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --border: #e4e8ee;
  --text: #2d3543;
  --text-soft: #71808f;
  --green: #12855f;
  --green-bg: #e3f5ee;
  --red: #c4392f;
  --red-bg: #fdeae8;
  --amber: #946200;
  --amber-bg: #fdf3dd;
  --blue: #2563ab;
  --blue-bg: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 32, 44, 0.05), 0 4px 16px rgba(24, 32, 44, 0.06);
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
p { margin: 0; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 8px; border: 1px solid transparent;
  padding: 9px 16px; font-weight: 550; text-decoration: none; color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-outline { background: var(--surface); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: #c9d1dc; }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(45, 53, 67, 0.06); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a92e25; }
.btn-sm { padding: 6px 12px; font-size: 0.92rem; }
.btn-block { width: 100%; }

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(255, 109, 90, 0.12), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(37, 99, 171, 0.10), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  padding: 36px 32px; text-align: center;
}
.login-logo { margin-bottom: 14px; }
.login-card h1 { font-size: 1.45rem; }
.login-subtitle { color: var(--text-soft); margin: 6px 0 24px; }
.login-card form { text-align: left; display: grid; gap: 6px; }
.login-card label { font-size: 0.86rem; font-weight: 600; color: var(--text-soft); margin-top: 8px; }
.login-card input {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fbfcfe;
}
.login-card input:focus { outline: 2px solid rgba(255, 109, 90, 0.35); border-color: var(--accent); }
.login-card form .btn { margin-top: 18px; }
.login-divider {
  display: flex; align-items: center; gap: 12px; color: var(--text-soft);
  font-size: 0.85rem; margin: 18px 0 12px;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-footnote { color: var(--text-soft); font-size: 0.82rem; margin-top: 22px; }
.alert {
  background: var(--red-bg); color: var(--red); border-radius: 8px;
  padding: 10px 12px; font-size: 0.9rem; margin-bottom: 14px; text-align: left;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 4px; color: var(--text-soft); font-size: 0.9rem; }
.sync-status { font-size: 0.82rem; color: var(--text-soft); }
.sync-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--green); }
.sync-status.error .dot { background: var(--red); }

/* ---------- Layout ---------- */
.layout { display: flex; height: calc(100vh - 56px); }
.sidebar {
  width: 320px; min-width: 240px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.sidebar-header { padding: 14px; border-bottom: 1px solid var(--border); }
.sidebar-header input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; background: #fbfcfe;
}
.sidebar-header input:focus { outline: 2px solid rgba(255, 109, 90, 0.3); border-color: var(--accent); }
.workflow-list { overflow-y: auto; flex: 1; padding: 8px; }
.workflow-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 2px;
}
.workflow-item:hover { background: rgba(45, 53, 67, 0.05); }
.workflow-item.selected { background: rgba(255, 109, 90, 0.1); }
.workflow-item .wf-name { font-weight: 570; display: flex; align-items: center; gap: 8px; }
.workflow-item .wf-meta { color: var(--text-soft); font-size: 0.8rem; margin-top: 3px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.active { background: var(--green); }
.status-dot.inactive { background: #c3ccd7; }
.status-dot.deleted { background: var(--red); }
.wf-deleted-label { color: var(--red); font-size: 0.75rem; font-weight: 600; }

.content { flex: 1; overflow-y: auto; padding: 28px 34px; }
.content-wide { max-width: 1000px; margin: 0 auto; }
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: var(--text-soft); text-align: center;
}
.empty-state h2 { color: var(--text); font-size: 1.15rem; }

/* ---------- Workflow detail ---------- */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.detail-header h2 { font-size: 1.35rem; }
.detail-sub { color: var(--text-soft); font-size: 0.9rem; margin-top: 4px; }
.open-in-n8n { white-space: nowrap; }

.timeline { margin-top: 26px; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 15px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border);
}
.version-card {
  position: relative; margin-left: 44px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.version-card::before {
  content: ""; position: absolute; left: -35px; top: 22px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--accent);
}
.version-card.layout-only::before { border-color: #c3ccd7; }
.version-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; flex-wrap: wrap;
}
.version-no { font-weight: 700; font-size: 1rem; }
.version-date { color: var(--text-soft); font-size: 0.86rem; }
.version-spacer { flex: 1; }
.version-actions { display: flex; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 650; padding: 3px 10px;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: #eef1f5; color: var(--text-soft); }

.version-note {
  padding: 0 18px 12px; color: var(--text); font-size: 0.92rem;
}
.version-note .note-label { color: var(--text-soft); font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }

.version-body { border-top: 1px solid var(--border); padding: 16px 18px; }
.change-grid { display: grid; gap: 8px; }
.change-row { display: flex; align-items: baseline; gap: 10px; font-size: 0.92rem; flex-wrap: wrap; }
.change-row .chg-what { color: var(--text-soft); min-width: 90px; font-size: 0.82rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; }
.node-pill {
  background: #f1f4f8; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; font-size: 0.85rem; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.node-pill.added { background: var(--green-bg); border-color: transparent; color: var(--green); }
.node-pill.removed { background: var(--red-bg); border-color: transparent; color: var(--red); text-decoration: line-through; }
.node-pill.modified { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.param-list { color: var(--text-soft); font-size: 0.82rem; margin-left: 4px; }

.diff-toggle { margin-top: 14px; }
.diff-view {
  margin-top: 12px; background: #0f172a; border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem; line-height: 1.55;
}
.diff-hunk { padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.diff-hunk:last-child { border-bottom: 0; }
.diff-hunk-header { color: #7dd3fc; padding: 2px 14px; opacity: 0.75; }
.diff-line { padding: 1px 14px; white-space: pre; color: #cbd5e1; }
.diff-line.add { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.diff-line.del { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

/* ---------- Admin ---------- */
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px; }
.admin-section h3 { margin-bottom: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; color: var(--text-soft); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.data select { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: #fff; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.form-row input, .form-row select { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fbfcfe; }
.muted { color: var(--text-soft); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; }

/* ---------- Modal & toasts ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 32, 44, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  max-width: 460px; width: 100%; padding: 24px;
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-soft); font-size: 0.94rem; }
.modal textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 80px; margin-top: 12px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast-root { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: #1f2937; color: #f3f4f6; border-radius: 10px; padding: 12px 16px;
  font-size: 0.9rem; box-shadow: var(--shadow); max-width: 360px;
  animation: toast-in 0.18s ease;
}
.toast.error { background: #7f1d1d; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; max-height: 40vh; }
  .content { padding: 18px; }
  .topbar { padding: 0 12px; }
  .user-chip #user-email { display: none; }
}
