/* =========================================================
   styles.css (refactored)
   Basis: original static.zip styles.css
   - No visual redesign intended
   - Inline styles moved into component-specific classes
   - Component-specific blocks are clearly separated
   ========================================================= */

/* ==================== Design Tokens ==================== */
:root{
  /* Farben */
  --bg: #f6f7f9;
  --surface: #fff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;

  --primary: #3b82f6;
  --primary-600: #2563eb;
  --danger: #ef4444;

  /* Effekte */
  --focus-ring: 0 0 0 3px rgba(59,130,246,.15);

  /* Radius & Schatten */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-sm: 0 4px 14px rgba(0,0,0,.06);
  --shadow-md: 0 8px 20px rgba(0,0,0,.08);

  /* Abstände */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
}

/* ==================== Base / Reset ==================== */
*,
*::before,
*::after { box-sizing: border-box; }

:where(h1,h2,h3,h4,h5,h6,p){ margin:0; }

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  padding: 2rem;
  background: var(--bg);
  color: var(--text);
}

/* Headings & labels */
h1{ margin-bottom: 1rem; font-size: 1.4rem; }
label{ display:block; margin-top: .75rem; font-weight: 600; }

/* ==================== TopHeader ==================== */
.topheader{
  text-align:center;
  margin-bottom:1rem;
}
.topheader h1{ margin-bottom:.5rem; font-size:1.5rem; }
.topheader p{ margin-bottom:0; }

/* ==================== Form Controls ==================== */
input, select, textarea, button{ display:block; }

input, select, textarea{
  width: 100%;
  padding: .6rem .75rem;
  margin-top: .25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* Buttons */
button{
  width: 100%;
  max-width: max-content;
  margin-top: 1rem;
  padding: .75rem 1rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s ease, background .2s ease, box-shadow .2s ease;
}
button:hover{ box-shadow: 0 8px 24px rgba(59,130,246,.25); transform: translateY(-1px); }
button:active{ transform: translateY(0); }
button:disabled{ background: #93c5fd; cursor: not-allowed; }

button:focus-visible{
  outline: 2px solid transparent;
  box-shadow: var(--focus-ring);
}

/* Text Utilities */
.muted{ color: var(--muted); font-size: .9rem; }
.error{ color: #b91c1c; margin-top: .5rem; }
.success{ color: #047857; margin-top: .5rem; }

/* ==================== Card (Login/Dashboard) ==================== */
.card{
  width: 100%;
  display: block;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.card .title {
  font-size: 1.25rem;
  font-weight: 450; /* Medium statt Bold (700) für einen moderneren Look */
  color: #2c3e50;
  margin: 0 0 5px 0;
  letter-spacing: -0.01em; /* Macht lange Titel etwas kompakter */
}

.card .subtitle {
  font-size: 0.9rem;
  font-weight: 400; /* Normale Stärke */
  color: #7f8c8d; /* Sanftes Grau für weniger Kontrast zum Titel */
  margin: 0 0 15px 0;
}

.sub-card {
  max-width: 1000px;
  margin: auto;
}
/* ... existing code ... */

/* ==================== Login: Sprachauswahl ==================== */
.login-form .lang-row{
  display:flex; justify-content:center; align-items:center;
  gap:.35rem; margin-bottom:.5rem;
  font-size:.85rem; line-height:1;
  color: var(--muted);
  user-select:none;
}
.login-form .lang-row a{
  text-decoration:none; color:inherit; opacity:.7; font-weight:500; letter-spacing:.03em;
}
.login-form .lang-row a.active{ opacity:1; text-decoration:underline; }
.login-form .lang-row a:hover,
.login-form .lang-row a:focus{ opacity:1; }
.login-form .lang-row .sep{ opacity:.5; padding:0 .25rem; }

.versionInfo{
  margin-top:2rem; text-align:center;
  font-size:.75rem; color: var(--muted);
}
/* ==================== Dashboard ==================== */
.dashboard{
  margin: 0 auto;
  padding: var(--space-5);
}
.dash-header{
  position: relative;
  display:grid; grid-template-columns: 1fr auto; gap: 1rem; align-items:start;
  margin-bottom: 1rem;
}
.title{ font-size: clamp(1.25rem, 2vw, 1.75rem); font-weight:700; }
.version{ margin:.15rem 0 .35rem; font-size:.9rem; }
.welcome{ margin:.25rem 0 .25rem; font-weight:600; }
.subtitle{ margin:.15rem 0 .75rem; }

/* Logout-Link oben rechts */
.logout-link{
  position:absolute; top:6px; right:0;
  font-size:.9rem; color: var(--muted);
  text-decoration:none; font-weight:600; line-height:1;
}
.logout-link:hover{ color: var(--text); text-decoration: underline; }
.logout-link:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; border-radius:4px; }

/* Nav-Kacheln */
.nav-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap:.9rem; margin-top:.75rem;
}
.nav-card{
  display:grid; grid-template-columns: 2.5rem 1fr; align-items:center; gap:.65rem;
  padding:.95rem 1rem;
  background: var(--surface);
  border:1px solid var(--border);
  color: var(--text);
  border-radius:14px;
  cursor:pointer; text-align:left;
  transition: box-shadow .2s ease, transform .06s ease, border-color .2s ease, background .2s ease;
  text-decoration: none;
}
.nav-card:hover{
  box-shadow: 0 6px 24px rgba(0,0,0,.06);
  transform: translateY(-1px);
  border-color:#d1d5db;
  background:#fcfcfd;
}
.nav-card:active{ transform: translateY(0); }
.nav-card .nav-icon{ display:inline-grid; place-items:center; font-size:1.35rem; }
.nav-card .nav-label{ font-weight:600; letter-spacing:.2px; }

/* ==================== Tabellen ==================== */
.table-wrap{ overflow:auto; }
.table{
  width:100%;
  border-collapse:collapse;
  background: var(--surface);
}
.table th, .table td{ padding:.5rem .6rem; border:1px solid var(--border); }
.table thead th{ background:#f3f4f6; text-align:left; font-weight:700; }
.table tbody tr:nth-child(even){ background:#fafafa; }

/* ==================== App-Layout / Full-Bleed Subviews ==================== */
.app-root{ min-height:100vh; display:flex; flex-direction:column; }
.main{ flex:1 1 auto; }

.full-bleed{
  /* Body-Padding neutralisieren → echte Vollfläche */
  margin: -2rem;
  min-height: 100vh;
  display:block;
}
@media (max-width:640px){
  body{ padding:1rem; }
  .dashboard{ padding:.75rem; }
  .full-bleed{ margin:-1rem; }
}

/* Subview-Panel */
.view-panel{
  position: relative;
  margin: 5px;
  min-height: calc(100% - 10px);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Close-X */
.close-x{
  position:absolute; top:10px; right:10px;
  width:auto; margin:0; padding:0; border:none; border-radius:8px;
  background:transparent; color:var(--muted);
  font-size:1.15rem; font-weight:700; line-height:1;
  cursor:pointer;
  transition: color .15s ease, transform .06s ease, background .15s ease;
}
.close-x:hover{ color:var(--text); background: rgba(0,0,0,.03); }
.close-x:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; }

/* ==================== Lists & Cards (vereinheitlicht) ==================== */
.list { display: grid; gap: .5rem; }

.card-item{
  width: 100%;
  display: block;
  padding: .75rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* klickbare Variante */
.card-item--clickable{
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, border-color .2s ease;
}
.card-item--clickable:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: #d1d5db;
}
.card-item--clickable:focus-visible{
  outline: 2px solid transparent;
  box-shadow: var(--focus-ring);
}

/* Inhaltshilfsklassen */
.row{
  display:flex; justify-content:space-between; gap:.75rem; align-items:baseline;
}
.title{ line-height:1.2; }
.subtitle{ opacity:.75; }
.path{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width: 65%; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.overlay-card {
  background: #fff; max-width: 900px; width: 92%; max-height: 85vh; overflow: auto;
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
  padding: 1rem 1.25rem; position: relative;
}
.overlay .close-x {
  position: absolute; top: .5rem; right: .75rem;
  background: transparent; border: 0; font-size: 1.5rem; line-height: 1;
  cursor: pointer;
}

/* ==================== Settings / Personal Settings ==================== */

/* Formgruppierung ähnlich Bootstrap */
.form-field {
  margin-top: 1rem;
}

/* Labels bereits oben definiert, aber hier etwas straffer */
.form-field > label {
  margin-bottom: .25rem;
  font-weight: 600;
}

/* Button-Row – zwei Buttons nebeneinander */
.btn-row {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
}

.btn-row .btn {
  flex: 0 0 auto;
}

/* Switch-Control für Checkbox (modernes Toggle-Design) */
.switch {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .5rem;
}

.switch input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--primary);   /* moderner Browser unterstützt dies */
  cursor: pointer;
}

.switch span {
  font-size: 0.95rem;
  user-select: none;
}

/* Spacing bei Hilfstext (muted paragraphs) */
.form-field p.muted {
  margin-top: .25rem;
  margin-bottom: .25rem;
  font-size: .9rem;
  line-height: 1.3;
}

/* Panel-Abstand */
.card + .card {
  margin-top: 1.25rem;
}

/* Readonly Input sichtbarer */
input[readonly] {
  background: #f3f4f6;
  cursor: default;
}

/* Textarea in Settings */
textarea.form-control {
  min-height: 130px;
  font-family: monospace;
  font-size: .95rem;
}

/* Hervorhebung Error Input – passt sich vorhandenen .error an */
input.invalid, textarea.invalid, select.invalid {
  border-color: var(--danger);
}

/* Hinweis: Flexibles Layout für Settings */
.settings-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .settings-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/*================ LogsOutput ==================*/
.logs-layout {
  display: flex;
  flex-direction: column;   /* 👈 WICHTIG */
  gap: 1rem;
  height: 100%;
}

.logs-list {
  width: 100%;              /* statt 320px */
}

.logs-content {
  flex: 1;                  /* nimmt den restlichen Platz ein */
  overflow: hidden;
}

.logs-list table {
  border-collapse: collapse;
  width: 100%;
}

.logs-list td,
.logs-list th {
  border: 1px solid #ccc;
  padding: 4px 6px;
}

.logs-list a.active {
  font-weight: bold;
  text-decoration: underline;
}

pre {
  white-space: pre-wrap;
  max-height: 60vh;         /* besser für unten */
  overflow: auto;
}

.tree-explorer {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}

/* Titel */
.tree-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .5rem;
  font-weight: 700;
}

/* Aktionen unter dem Baum */
.tree-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}

/* Reset-Link ohne X */
.tree-reset {
  font-size: .8rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.tree-reset:hover {
  color: var(--text);
}

/* ==================== TOTP Dialog (zentriert) ==================== */

.overlay-card--sm{
  max-width: 420px;
  width: 92%;
}

.totp-centered{
  display: flex;
  flex-direction: column;
  align-items: center;     /* ✅ alles horizontal zentriert */
  text-align: center;      /* ✅ Texte zentriert */
}

.totp-title{
  margin-bottom: var(--space-3);
}

.totp-section{
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.totp-text{
  width: 100%;
}

.totp-qr{
  display: block;
  width: 300px;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.totp-input{
  width: 100%;
  text-align: center;  /* ✅ Code-Eingabe zentriert */
}

.totp-actions{
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;      /* ✅ Buttons zentriert */
  gap: var(--space-2);
}

/* Switch zentriert (Checkbox + Text mittig) */
.switch--center{
  justify-content: center;
}

/* Optional: sekundärer Button Stil */
.btn--secondary{
  background: #e5e7eb;
  color: var(--text);
}
.btn--secondary:hover{
  box-shadow: var(--shadow-sm);
}

/* Error optisch mittig halten */
.totp-error{
  text-align: center;
  width: 100%;
}

/* =========================================================
   Component: LoginForm
   ========================================================= */
.login__error{
  margin-top:.5rem;
  color:#b00020;
}

/* =========================================================
   Component: Clients
   ========================================================= */
.clients__displayname{ margin-top:.25rem; }
.clients__loading{ margin:.5rem 0; }
.clients__empty{ margin-top:.75rem; }

/* =========================================================
   Component: VersionManager
   ========================================================= */
.version-manager__section{ margin-top:1em; }

/* =========================================================
   Component: PersonalSettings
   ========================================================= */
.personal-settings__loading{ margin:.5rem 0; }
.personal-settings__msg{ margin:.5rem 0; }
.personal-settings__section{ margin-top:.75rem; }
.personal-settings__h3{ margin-top:0; }

/* =========================================================
   Component: Statistics
   ========================================================= */
.statistics__loading{ margin:.5rem 0; }
.no-scroll{ overflow:hidden; }

/* =========================================================
   Component: UploadDetails (Popup)
   ========================================================= */
.upload-details__attr-col{ width:40%; }

/* Make the details popup scroll within viewport */
.upload-details__overlay-card{
  max-height: 90vh;
  overflow: auto;
}

/* =========================================================
   Component: YearStats
   ========================================================= */
.year-stats__header{ margin:.5rem 0 1rem; }
.year-stats__pre{
  margin-top:1rem;
  white-space:pre-wrap;
  font-size:.9rem;
}

/* =========================================================
   Component: ClientEntry (Tree)
   ========================================================= */
.client-entry__tree{ margin-left:15px; font-family:sans-serif; }
.client-entry__node{
  cursor:pointer;
  padding:2px 5px;
  border-radius:3px;
}
.client-entry__node--selected{
  background:#e7f1ff;
  color:#0056b3;
  font-weight:bold;
}
.client-entry__icon{ margin-right:5px; }
.client-entry__row{ align-items:center; margin-bottom:1rem; }
.client-entry__overlay-card{ max-width:500px; }

/* =========================================================
   Component: UploadStatus
   ========================================================= */
.upload-status__autorefresh label{
  display: inline-block;   /* überschreibt globales block */
  width: auto;
  margin-top: 0;           /* optional: Abstand kontrollieren */
  cursor: pointer;
}

.upload-status__autorefresh input[type="checkbox"]{
  display: inline-block;   /* überschreibt input{display:block} */
  width: auto;             /* verhindert volle Breite */
  margin: 0 .4rem 0 0;
  vertical-align: middle;
}

.upload-status__checkbox{
  accent-color: var(--primary, #2563eb);
}

.upload-status__failed{ margin-top:1rem; }
.upload-status__autorefresh{ margin-top:1rem; }

.upload-status__toggle{
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  user-select: none;
}

.upload-status__toggle:hover{
  opacity: .85;
}

.upload-status__chevron{
  font-size: .9em;
  color: var(--muted);
}

.clients__list{ margin-top:.5rem; }

.statistics__table{ margin-top:.5rem; }
.statistics__mr{ margin-right:.35rem; }
.statistics__h5{ margin-top:1rem; }
.statistics__span{ margin:0 .5rem; }
.statistics__section{ margin-top:1rem; }

.year-stats__year{ margin:0 .5rem; }

.personal-settings__card{ margin-top:1rem; }

.upload-status__mt-sm{ margin-top:.5rem; }
.upload-status__mx{ margin:0 .5rem; }
.upload-status__ml{ margin-left:.5rem; }
.upload-status__mr{ margin-right:.35rem; }
.upload-status__mt{ margin-top:1rem; }
