/*
 * NyxLockPass dark theme. Mobile-friendly, no external font assets.
 *
 * Palette: deep violet + cyan night accents over near-black background.
 * Layout: 280px sidebar + workspace; collapses to single column on narrow
 * screens. Auth and downloads pages share the same brand surface.
 */

:root {
  --bg: #07060d;
  --bg-2: #0b0a14;
  --panel: #13111c;
  --panel-2: #1b1729;
  --panel-3: #221c34;
  --line: #2c2640;
  --line-strong: #3d3457;
  --text: #f5f1ff;
  --muted: #a89dbd;
  --muted-soft: #837993;
  --violet: #8b5cf6;
  --violet-deep: #6d28d9;
  --violet-bright: #a78bfa;
  --cyan: #22d3ee;
  --cyan-soft: #67e8f9;
  --green: #34d399;
  --amber: #fbbf24;
  --danger: #fb7185;
  --danger-strong: #f43f5e;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 10px 32px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-soft); text-decoration: underline; }

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; color: var(--text); margin: 12px 0 6px; }
h4 { font-size: 0.9rem; font-weight: 700; margin: 14px 0 6px; color: var(--muted); }
p  { color: var(--muted); }

.muted   { color: var(--muted); }
.hidden  { display: none !important; }
.danger  { color: var(--danger); }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* -- Shell ----------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.18), transparent 36%),
    linear-gradient(315deg, rgba(34, 211, 238, 0.10), transparent 30%),
    var(--bg);
}

.app-shell.auth-mode {
  grid-template-columns: 1fr;
  background:
    radial-gradient(circle at 50% 12%, rgba(139, 92, 246, 0.20), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(34, 211, 238, 0.12), transparent 30%),
    linear-gradient(180deg, #08070f, #04030a);
}

.app-shell.auth-mode .main { grid-column: 1; }

/* -- Sidebar --------------------------------------------------------------- */

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(11, 9, 18, 0.92);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  min-height: 100vh;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  border-radius: 10px;
  filter: drop-shadow(0 8px 22px rgba(139, 92, 246, 0.32));
}
.brand-mark.large {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.brand-name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.brand-state {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}
.nav-tab {
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: 42px;
  transition: background 120ms ease, border-color 120ms ease;
}
.nav-tab:hover { border-color: var(--line-strong); background: rgba(33, 23, 53, 0.5); }
.nav-tab.active {
  border-color: rgba(139, 92, 246, 0.85);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.30), rgba(34, 211, 238, 0.10));
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.10);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

/* -- Buttons --------------------------------------------------------------- */

.ghost-button, .secondary-button, .primary-button, .ghost-link, .toolbar-link {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.ghost-button {
  background: transparent;
}
.ghost-button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
}
.ghost-button:hover,
.ghost-link:hover,
.secondary-button:hover,
.toolbar-link:hover {
  border-color: rgba(139, 92, 246, 0.7);
  background: rgba(33, 23, 53, 0.6);
}

.ghost-button.danger { color: var(--danger); border-color: rgba(251, 113, 133, 0.32); }
.ghost-button.danger:hover { background: rgba(251, 113, 133, 0.10); border-color: var(--danger); }

.primary-button {
  border-color: rgba(139, 92, 246, 0.95);
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  font-weight: 800;
  color: #fff;
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.32);
}
.primary-button:hover { filter: brightness(1.1); }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.secondary-button { background: var(--panel-2); }

.ghost-link {
  background: transparent;
  text-decoration: none;
  padding: 9px 14px;
  text-align: center;
}

.toolbar-link {
  text-decoration: none;
  font-weight: 600;
}

.download-link {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin: -4px 0 20px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.9rem;
}
.download-link:hover { color: var(--cyan-soft); text-decoration: underline; }

/* -- Auth panel ------------------------------------------------------------ */

.main { min-width: 0; }

.auth-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 18px;
}

.auth-box {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(27, 23, 41, 0.96), rgba(13, 11, 22, 0.96)),
    var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  border-radius: 14px;
  padding: 32px;
}

.auth-brand {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
  margin-bottom: 18px;
}
.auth-brand > div { display: grid; gap: 6px; }

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-help {
  border: 1px solid rgba(139, 92, 246, 0.36);
  background: rgba(139, 92, 246, 0.08);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.88rem;
}
.auth-help.muted {
  border-style: dashed;
  border-color: var(--line);
  background: transparent;
  color: var(--muted-soft);
  text-align: center;
}

/* -- Inputs ---------------------------------------------------------------- */

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0c0a14;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.20);
}
textarea {
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
}

input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--violet);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0;
  display: grid;
  gap: 6px;
}
fieldset legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.84rem;
}
fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

/* -- Workspace ------------------------------------------------------------- */

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: rgba(8, 7, 14, 0.78);
  backdrop-filter: blur(10px);
}

.search-wrap { display: contents; }
.search-wrap input[type="search"] { max-width: 540px; }

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* -- Views ----------------------------------------------------------------- */

.view {
  display: none;
  padding: 22px;
}
.view.active { display: block; }

.vault-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 116px);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
  max-height: calc(100vh - 140px);
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.entry-item {
  list-style: none;
  border-radius: var(--radius);
}
.entry-item.empty {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  text-align: center;
}

.entry-item-button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  transition: border-color 120ms ease, background 120ms ease;
}
.entry-item-button:hover,
.entry-item.active .entry-item-button {
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(33, 23, 53, 0.55);
}

.entry-item-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.entry-item-text strong {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-meta {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-type-badge {
  border-radius: 999px;
  font-size: 0.66rem;
  padding: 3px 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(13, 11, 22, 0.85);
}
.entry-type-badge.type-login    { color: var(--cyan); border-color: rgba(34, 211, 238, 0.38); }
.entry-type-badge.type-card     { color: var(--violet-bright); border-color: rgba(167, 139, 250, 0.38); }
.entry-type-badge.type-note     { color: var(--green); border-color: rgba(52, 211, 153, 0.38); }
.entry-type-badge.type-identity { color: var(--amber); border-color: rgba(251, 191, 36, 0.38); }

.fav-star {
  color: var(--amber);
  font-weight: 800;
}

/* -- Entry details pane ---------------------------------------------------- */

.entry-details {
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.92);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
}

.empty-detail {
  color: var(--muted);
  text-align: center;
  padding: 32px;
}

.details-header { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.details-header h2 { font-size: 1.4rem; }
.details-actions  { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.details-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.details-label {
  color: var(--muted);
  font-size: 0.84rem;
  padding-top: 4px;
}
.details-value {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  word-break: break-word;
}
.details-value a { color: var(--cyan); }
.details-value pre {
  margin: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
  font-size: 0.86rem;
  color: var(--text);
  width: 100%;
}

.masked {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
  letter-spacing: 0.12em;
}

.details-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip {
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.32);
  color: var(--cyan-soft);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
}

/* -- Generator ------------------------------------------------------------- */

.generator {
  max-width: 760px;
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.92);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 16px;
}

.generator-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.generator-output input {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
  color: var(--cyan);
  font-size: 0.95rem;
}

.generator-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.generator-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
}
.generator-controls label input[type="number"] {
  width: 90px;
  margin-left: auto;
}

/* -- Import panel ---------------------------------------------------------- */

.import-panel {
  max-width: 760px;
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.92);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
}

.file-drop {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  display: block;
  transition: border-color 120ms ease, background 120ms ease;
}
.file-drop:hover {
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.06);
  color: var(--text);
}
.file-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.import-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 12px;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}
.import-preview p { color: var(--text); margin-bottom: 6px; }
.import-preview ul { margin: 0; padding-left: 18px; }
.import-preview li { color: var(--muted); }

/* -- Settings -------------------------------------------------------------- */

.settings-panel {
  max-width: 720px;
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.92);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
}
.settings-panel form { display: grid; gap: 14px; }

.audit-report {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 14px;
  min-height: 60px;
}
.audit-report h4 { margin-top: 14px; }
.audit-report ul { margin: 0; padding-left: 18px; color: var(--muted); }
.audit-report li { margin: 4px 0; }

/* -- Dialog ---------------------------------------------------------------- */

dialog.entry-dialog {
  width: min(540px, 92vw);
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog.entry-dialog::backdrop {
  background: rgba(4, 3, 10, 0.78);
  backdrop-filter: blur(4px);
}
dialog.entry-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}
dialog.entry-dialog h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
}
dialog.entry-dialog .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* -- Toast ----------------------------------------------------------------- */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(33, 28, 52, 0.95), rgba(19, 17, 28, 0.95));
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 0.9rem;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* -- Downloads page -------------------------------------------------------- */

.downloads-page {
  min-height: 100vh;
  padding: 28px 22px;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.18), transparent 36%),
    linear-gradient(315deg, rgba(34, 211, 238, 0.10), transparent 30%),
    var(--bg);
}
.downloads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto 36px;
}
.download-brand {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.download-brand:hover { text-decoration: none; }
.download-brand span { display: block; }

.download-hero,
.download-layout {
  max-width: 1120px;
  margin: 0 auto;
}
.download-hero { margin-bottom: 28px; }
.download-hero h1 {
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  max-width: 860px;
  margin-bottom: 10px;
}
.download-hero p {
  max-width: 720px;
  font-size: 1.02rem;
}

.download-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 18px;
}

.tool-panel {
  border: 1px solid var(--line);
  background: rgba(19, 17, 28, 0.92);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
}
.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: var(--green);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.status-pill.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.5); }
.status-pill.error { color: var(--danger); border-color: rgba(251, 113, 133, 0.5); }

.security-lines {
  display: grid;
  gap: 10px;
}
.security-lines > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.security-lines > div:first-child { border-top: 0; padding-top: 0; }
.security-lines span { color: var(--muted); }

.release-list {
  display: grid;
  gap: 10px;
}
.release-empty,
.release-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 14px;
}
.release-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.release-item span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.extension-guide {
  max-width: 1120px;
  margin: 20px auto 0;
}
.install-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.install-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 16px;
}
.install-card h3 { margin: 0 0 10px; }
.install-card ol { margin: 0; padding-left: 20px; color: var(--muted); }
.install-card li + li { margin-top: 8px; }
.install-card code {
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 0.88em;
}

/* -- Responsive ------------------------------------------------------------ */

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    gap: 16px;
  }
  .nav-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .nav-tab { text-align: center; padding: 8px 10px; }
  .sidebar-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .download-layout { grid-template-columns: 1fr; }
  .install-grid { grid-template-columns: 1fr; }
  .vault-grid { grid-template-columns: 1fr; min-height: auto; }
  .entry-list { max-height: 50vh; }
}

@media (max-width: 640px) {
  .toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .downloads-header { display: grid; }
  .release-item { grid-template-columns: 1fr; }
  .auth-panel, .view { padding: 14px; }
  .auth-box, .generator, .import-panel, .settings-panel, .entry-details { padding: 16px; }
  .details-row { grid-template-columns: 1fr; }
  .details-label { padding-top: 0; }
  .nav-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
