/* ─────────────────────────────────────────────
   Fourtytwo – Stylesheet
   Design: Dunkel, minimalistisch, seriös
   Layout: Sidebar + Content
   ───────────────────────────────────────────── */

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #22263a;
  --border:       #2c3050;
  --accent:       #6c63ff;
  --accent-hover: #5a52e0;
  --danger:       #e05252;
  --success:      #52c878;
  --warn:         #e0a852;
  --text:         #e8eaf0;
  --text-muted:   #8890a8;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w:    220px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }


/* ─────────────────────────────────────────────
   Auth-Seite
   ───────────────────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem; min-height: 100vh;
}
.auth-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2.5rem 2rem; width: 100%; max-width: 420px;
}
.logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 2.5rem; }
.logo h1   { font-size: 1.8rem; font-weight: 700; margin-top: 0.25rem; }
.tagline   { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  flex: 1; background: none; border: none; color: var(--text-muted);
  padding: 0.65rem 1rem; cursor: pointer; font-size: 0.95rem; transition: color 0.2s;
}
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.tab:hover  { color: var(--text); }


/* ─────────────────────────────────────────────
   Formulare
   ───────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
label .hint { font-size: 0.78rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 0.65rem 0.9rem; font-size: 0.95rem; outline: none; transition: border-color 0.2s;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }

.select-field {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 0.65rem 0.9rem; font-size: 0.95rem; outline: none; cursor: pointer;
}
.select-field:focus { border-color: var(--accent); }

.password-row { display: flex; gap: 0.4rem; align-items: center; }
.password-row input { flex: 1; }


/* ─────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); padding: 0.75rem 1.25rem;
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.2s; margin-top: 0.5rem;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary.btn-sm { width: auto; padding: 0.5rem 1rem; font-size: 0.88rem; margin-top: 0; white-space: nowrap; }

.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius); padding: 0.5rem 1rem; cursor: pointer; font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-ghost.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.btn-secondary {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 0.5rem 1rem; cursor: pointer; font-size: 0.9rem;
}
.btn-secondary:hover { background: var(--border); }

.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 0.25rem 0.4rem; border-radius: 6px; transition: background 0.15s; color: var(--text-muted);
}
.btn-icon:hover        { background: var(--surface-2); color: var(--text); }
.btn-icon.danger:hover { background: rgba(224,82,82,0.15); color: var(--danger); }


/* ─────────────────────────────────────────────
   Feedback
   ───────────────────────────────────────────── */
.error-msg {
  background: rgba(224,82,82,0.1); border: 1px solid var(--danger);
  border-radius: var(--radius); color: var(--danger); font-size: 0.88rem;
  padding: 0.6rem 0.9rem; margin-top: 0.75rem;
}
.success-msg {
  background: rgba(82,200,120,0.1); border: 1px solid var(--success);
  border-radius: var(--radius); color: var(--success); font-size: 0.88rem;
  padding: 0.6rem 0.9rem; margin-top: 0.75rem;
}
.info-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 1rem; text-align: center; line-height: 1.5; }


/* ─────────────────────────────────────────────
   App-Layout (Header + Sidebar + Content)
   ───────────────────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.header-left { display: flex; align-items: center; gap: 0.5rem; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }
.logo-icon-small { font-size: 1.2rem; }
.app-name { font-weight: 700; font-size: 1rem; }
.username-badge {
  font-size: 0.8rem; color: var(--text-muted); background: var(--surface-2);
  padding: 0.25rem 0.6rem; border-radius: 20px; border: 1px solid var(--border);
}

.hamburger {
  display: none; background: none; border: none; color: var(--text);
  font-size: 1.4rem; cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 6px;
}
.hamburger:hover { background: var(--surface-2); }

/* Body = Sidebar + Content */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  overflow-y: auto; height: calc(100vh - 49px); position: sticky; top: 49px;
}
.sidebar-nav { padding: 0.75rem 0.5rem 0.25rem; }
.sidebar-divider { height: 1px; background: var(--border); margin: 0.4rem 0.75rem; }
.sidebar-label {
  font-size: 0.68rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; padding: 0.5rem 1rem 0.25rem;
}
.sidebar-categories { padding: 0 0.5rem 0.5rem; }
.sidebar-footer { padding: 0.25rem 0.5rem 0.75rem; }

.nav-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  background: none; border: none; color: var(--text-muted); padding: 0.5rem 0.75rem;
  border-radius: 8px; cursor: pointer; font-size: 0.88rem; transition: all 0.15s; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }

.cat-item {
  display: block; width: 100%; background: none; border: none;
  color: var(--text-muted); padding: 0.35rem 0.75rem; border-radius: 6px;
  cursor: pointer; font-size: 0.82rem; text-align: left; transition: all 0.15s;
}
.cat-item:hover { background: var(--surface-2); color: var(--text); }
.cat-item.active { color: var(--accent); font-weight: 600; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 14;
}

/* ── Content ─────────────────────────────── */
.content { flex: 1; overflow-y: auto; height: calc(100vh - 49px); padding: 1.25rem 1.5rem; }
.content-view { max-width: 820px; }

.content-header {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
}
.content-header h2 { font-size: 1.05rem; font-weight: 700; }
.content-header .search-input { flex: 1; }


/* ─────────────────────────────────────────────
   Einträge
   ───────────────────────────────────────────── */
.loading-indicator { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; }
.spinner {
  display: inline-block; width: 1rem; height: 1rem;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 0.4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.entries-list { display: flex; flex-direction: column; gap: 0.35rem; }

.entry-card {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.85rem; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.entry-card:hover { border-color: var(--accent); background: var(--surface-2); }
.entry-icon     { width: 28px; text-align: center; font-size: 1.1rem; flex-shrink: 0; }
.entry-info     { flex: 1; min-width: 0; }
.entry-title    { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-username { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-actions  { display: flex; gap: 0.15rem; flex-shrink: 0; }

.category-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 600;
  padding: 0.05rem 0.4rem; border-radius: 3px;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
  vertical-align: middle; margin-left: 0.35rem;
}
.category-header {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 1rem 0 0.3rem 0.2rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem;
}
.category-header:first-child { padding-top: 0; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.95rem; line-height: 2; }
.no-results  { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.9rem; }


/* ─────────────────────────────────────────────
   Modals
   ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem 0.65rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.1rem;
  cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 6px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body, .view-content { padding: 1rem 1.25rem; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 0.65rem 1.25rem 1rem; border-top: 1px solid var(--border);
}
.modal-actions .btn-primary { width: auto; margin-top: 0; }

.view-field { margin-bottom: 0.85rem; }
.view-field label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 0.15rem;
}
.view-value-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.password-hidden { font-family: monospace; letter-spacing: 0.2em; color: var(--text-muted); }
.view-notes { font-size: 0.85rem; color: var(--text-muted); white-space: pre-wrap; }


/* ─────────────────────────────────────────────
   Nachrichten
   ───────────────────────────────────────────── */
.msg-compose { margin-bottom: 1.25rem; }
.msg-compose textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 0.55rem 0.8rem;
  font-size: 0.88rem; font-family: inherit; resize: vertical; outline: none;
}
.msg-compose textarea:focus { border-color: var(--accent); }
.messages-list { display: flex; flex-direction: column; gap: 0.4rem; }

.author-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.author-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--surface); border: none; color: var(--text); padding: 0.6rem 0.85rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.author-header:hover { background: var(--surface-2); }
.msg-count {
  background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 700;
  padding: 0.08rem 0.45rem; border-radius: 10px; min-width: 1.2rem; text-align: center;
}
.author-messages { display: none; padding: 0.4rem; background: var(--bg); }
.author-group.open .author-messages { display: block; }

.message-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.6rem 0.85rem; margin-bottom: 0.3rem;
}
.message-card:last-child { margin-bottom: 0; }
.message-text { font-size: 0.85rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.message-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 0.3rem; font-size: 0.7rem; color: var(--text-muted);
}


/* ─────────────────────────────────────────────
   Benutzer-Liste
   ───────────────────────────────────────────── */
.users-list { display: flex; flex-direction: column; gap: 0.35rem; }
.user-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 1rem;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-email { font-size: 0.78rem; color: var(--text-muted); }
.user-date  { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }


/* ─────────────────────────────────────────────
   Admin-Logs
   ───────────────────────────────────────────── */
.admin-logs { overflow: auto; }
.log-table-wrap { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.log-table th {
  text-align: left; padding: 0.45rem 0.65rem; background: var(--surface-2);
  color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.log-table td {
  padding: 0.4rem 0.65rem; border-bottom: 1px solid var(--border);
  color: var(--text-muted); vertical-align: middle;
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--surface-2); }
.log-badge {
  display: inline-block; font-size: 0.65rem; font-weight: 600; padding: 0.12rem 0.4rem;
  border-radius: 3px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2); color: var(--text-muted);
}
.log-badge.log-login-ok, .log-badge.log-register-ok, .log-badge.log-vault-create {
  background: rgba(82,200,120,0.12); color: var(--success);
}
.log-badge.log-login-fail, .log-badge.log-register-fail {
  background: rgba(224,82,82,0.12); color: var(--danger);
}
.log-badge.log-vault-delete { background: rgba(224,82,82,0.08); color: var(--warn); }
.log-badge.log-vault-update { background: rgba(108,99,255,0.12); color: var(--accent); }


/* ─────────────────────────────────────────────
   CSV-Import
   ───────────────────────────────────────────── */
.file-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 0.5rem 0.8rem; font-size: 0.85rem;
}
.file-input::file-selector-button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 0.3rem 0.65rem; font-size: 0.78rem; font-weight: 600; cursor: pointer; margin-right: 0.65rem;
}
.import-preview { margin-top: 0.75rem; }
.import-count { font-size: 0.85rem; color: var(--accent); font-weight: 600; margin-bottom: 0.4rem; }
.import-progress { margin-top: 0.75rem; }
.progress-bar { width: 100%; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.2s ease; }
.progress-text { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; text-align: center; }


/* ─────────────────────────────────────────────
   Mobile (< 768px)
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: block; }

  .sidebar {
    position: fixed; top: 0; left: -280px; width: 260px; min-width: 260px;
    height: 100vh; z-index: 15; transition: left 0.25s ease;
    border-right: 1px solid var(--border); padding-top: 56px;
  }
  .sidebar.open { left: 0; }

  .content { padding: 0.75rem; height: auto; overflow: visible; }
  .content-header { gap: 0.5rem; margin-bottom: 0.75rem; }
  .content-header .search-input { font-size: 0.85rem; padding: 0.5rem 0.7rem; }

  .entry-card { padding: 0.5rem 0.7rem; gap: 0.5rem; }
  .entry-icon { width: 24px; font-size: 1rem; }
  .entry-title { font-size: 0.82rem; }
  .entry-username { font-size: 0.72rem; }
  .entry-actions .btn-icon { font-size: 0.85rem; padding: 0.2rem; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-height: 95vh; border-radius: var(--radius) var(--radius) 0 0; }

  .app-header { padding: 0.5rem 0.75rem; }
  .app-name { font-size: 0.9rem; }
  .username-badge { font-size: 0.72rem; padding: 0.2rem 0.5rem; }

  .log-table { font-size: 0.68rem; }
  .user-card { padding: 0.55rem 0.75rem; }
}

@media (max-width: 400px) {
  .entry-actions .btn-icon:not(:last-child) { display: none; }
  .header-right .btn-ghost { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
}
