/* inventio — Stylesheet (0.1) */

:root {
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --bg-sidebar: #f0efed;
  --text: #1a1a1a;
  --text-secondary: #555;
  --border: #ddd;
  --accent: #2d5a27;
  --accent-hover: #3d7a35;
  --danger: #a33;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-card: #252525;
    --bg-sidebar: #141414;
    --text: #e8e8e8;
    --text-secondary: #aaa;
    --border: #333;
    --accent: #5a9e52;
    --accent-hover: #6db865;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
}

/* ── Sidebar ── */

#sidebar {
  width: 200px;
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
}

#sidebar .logo {
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0 1.2rem 1rem;
  letter-spacing: 0.02em;
}

#sidebar ul {
  list-style: none;
  flex: 1;
}

#sidebar li a {
  display: block;
  padding: 0.6rem 1.2rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s;
}

#sidebar li a:hover {
  background: var(--border);
  color: var(--text);
}

#sidebar li a.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  padding: 1rem 1.2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Main Content ── */

#content {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
  overflow-y: auto;
}

.panel { display: none; }
.panel.active { display: block; }

/* ── Suche ── */

.search-bar {
  margin-bottom: 1rem;
}

#search-input {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  overflow: hidden;
  min-height: 3rem;
}

.search-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.mode-toggle {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.mode-toggle label {
  cursor: pointer;
}

.case-toggle {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.limit-control {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.limit-control input {
  width: 3.5rem;
  padding: 0.4rem 0.3rem;
  font-size: 0.85rem;
  font-family: var(--font);
  text-align: center;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color-scheme: dark light;
}

#btn-search {
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

#btn-search:hover { background: var(--accent-hover); }
#btn-search:disabled { opacity: 0.5; cursor: not-allowed; }

.info-line {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  min-height: 1.2em;
}

/* ── Treffer-Cards ── */

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.result-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

.result-score {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.result-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}
.result-meta span[title] {
  cursor: help;
  text-decoration: underline dotted var(--text-secondary);
  text-underline-offset: 2px;
}

.result-passage {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.passage-score {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 0.2rem;
}

.result-passage .passage-pdf {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  padding-top: 0.15rem;
}

.result-passage .passage-pdf:hover {
  text-decoration: underline;
}

.result-snippet {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  border-left: 3px solid var(--border);
  padding-left: 0.8rem;
  margin-bottom: 0.6rem;
}

.result-passage .result-snippet {
  margin-bottom: 0;
}

.result-snippet mark {
  background: rgba(255, 200, 50, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.result-actions {
  display: flex;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.result-actions a,
.result-actions button {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.85rem;
  font-family: var(--font);
}

.result-actions a:hover,
.result-actions button:hover {
  text-decoration: underline;
}

.copied-feedback {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ── View-Toggle (Segmented Control) ── */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-right: 0.6rem;
  vertical-align: middle;
}

.view-btn {
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-family: var(--font);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 0;
  cursor: pointer;
  margin: 0;
  transition: background 0.15s, color 0.15s;
}

.view-btn:hover {
  background: var(--border);
}

.view-btn.active {
  background: var(--accent);
  color: #fff;
}

.view-btn + .view-btn {
  border-left: 1px solid var(--border);
}

/* ── Copy-Icon pro Passage ── */

.copy-passage-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0.15rem;
  margin: 0;
  margin-left: auto;
  cursor: pointer;
  color: var(--accent);
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
  vertical-align: middle;
}

.copy-passage-btn:hover {
  opacity: 1;
  background: transparent;
}

/* ── Import ── */

.import-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 500px;
}

.import-form input[type="text"] {
  padding: 0.6rem;
  font-size: 0.95rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Einstellungen ── */

.settings-form {
  max-width: 400px;
}

.settings-form label {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 0.3rem;
}

.settings-form input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.3rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

button {
  padding: 0.5rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

button:hover { background: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #c44;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Welcome ── */

.welcome {
  max-width: 600px;
}

.welcome h1 {
  font-size: 2rem;
  margin-bottom: 0.2rem;
}

.welcome .claim {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 2rem;
}

.welcome h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.welcome p, .welcome ol {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.welcome ol {
  padding-left: 1.5rem;
}

.welcome a {
  color: var(--accent);
}

.welcome h4 {
  margin-top: 1rem;
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

/* ── Hilfe-Beispiele (semantische Suche) ── */

.help-examples {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0.8rem;
}

.help-examples li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-example-query {
  color: var(--accent);
}

.help-example-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ── Hilfe-Tabelle (lexikalische Suche) ── */

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.help-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.help-table td:first-child {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  width: 1%;
}

.help-table td:last-child {
  color: var(--text-secondary);
}

/* ── Production-Sichtbarkeit ── */

body.production .server-hide { display: none !important; }
body:not(.production) .server-only { display: none !important; }

/* ── Passwort-Modal ── */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
}

.auth-modal .logo {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.auth-modal input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-modal .auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
}

/* ── Zeichenzähler ── */

.char-counter {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 0.2rem;
}

.char-counter.over-limit {
  color: var(--danger);
  font-weight: 600;
}

/* ── Responsive ── */

@media (max-width: 700px) {
  body { flex-direction: column; }
  #sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  #sidebar .logo { padding: 0 0.8rem 0 0; }
  #sidebar ul { display: flex; gap: 0; flex: 1; }
  #sidebar li a { padding: 0.4rem 0.8rem; }
  .sidebar-footer { display: none; }
  #content { padding: 1rem; }

  /* Treffer-Cards: Score drüber, Link weg, Passage volle Breite */
  .result-passage {
    flex-wrap: wrap;
  }
  .result-passage .passage-pdf {
    display: none;
  }
  .result-passage .passage-score {
    width: 100%;
    padding-top: 0;
  }
  .result-passage .result-snippet {
    width: 100%;
  }
}
