/*
 * StudiAI 6.5.8 – Darkmode-Korrektur für Formulare und Support
 * Sämtliche Regeln sind bewusst auf data-theme="dark" begrenzt.
 * Der Hellmodus wird dadurch nicht verändert.
 */

:root[data-theme="dark"]{
  color-scheme:dark;
}

/* Normale Formularfelder, auch außerhalb von .field */
:root[data-theme="dark"] body input:not(
  [type="checkbox"],
  [type="radio"],
  [type="range"],
  [type="color"],
  [type="button"],
  [type="submit"],
  [type="reset"],
  [type="image"]
),
:root[data-theme="dark"] body select,
:root[data-theme="dark"] body textarea,
:root[data-theme="dark"] body [contenteditable="true"]{
  color:var(--text)!important;
  -webkit-text-fill-color:var(--text);
  caret-color:#ffffff;
  background:var(--card-soft)!important;
  border-color:var(--line-strong)!important;
  box-shadow:none;
}

/* Datei-Uploads sollen ebenfalls zur dunklen Oberfläche passen */
:root[data-theme="dark"] body input[type="file"]{
  color:var(--muted-strong)!important;
  background:var(--card-soft)!important;
  border-color:var(--line-strong)!important;
}

:root[data-theme="dark"] body input[type="file"]::file-selector-button{
  margin-right:10px;
  padding:8px 11px;
  border:1px solid var(--line);
  border-radius:9px;
  color:var(--text);
  background:var(--surface-hover);
  cursor:pointer;
}

/* Platzhalter und Auswahllisten */
:root[data-theme="dark"] body input::placeholder,
:root[data-theme="dark"] body textarea::placeholder{
  color:var(--muted)!important;
  -webkit-text-fill-color:var(--muted);
  opacity:1;
}

:root[data-theme="dark"] body select option,
:root[data-theme="dark"] body select optgroup{
  color:var(--text);
  background:var(--card);
}

/* Fokus bleibt deutlich sichtbar, ohne weiß zu werden */
:root[data-theme="dark"] body input:not(
  [type="checkbox"],
  [type="radio"],
  [type="range"],
  [type="color"],
  [type="button"],
  [type="submit"],
  [type="reset"],
  [type="image"]
):focus,
:root[data-theme="dark"] body select:focus,
:root[data-theme="dark"] body textarea:focus,
:root[data-theme="dark"] body [contenteditable="true"]:focus{
  color:var(--ink)!important;
  background:var(--card-strong)!important;
  border-color:#568df0!important;
  box-shadow:0 0 0 4px var(--focus)!important;
  outline:none;
}

/* Deaktivierte und schreibgeschützte Felder */
:root[data-theme="dark"] body input:disabled,
:root[data-theme="dark"] body select:disabled,
:root[data-theme="dark"] body textarea:disabled,
:root[data-theme="dark"] body input[readonly],
:root[data-theme="dark"] body textarea[readonly]{
  color:var(--muted)!important;
  -webkit-text-fill-color:var(--muted);
  background:color-mix(in srgb,var(--card-soft) 78%,#000 22%)!important;
  border-color:var(--line)!important;
  opacity:1;
  cursor:not-allowed;
}

/* Chrome/Safari-Autofill darf die Felder nicht wieder weiß oder gelb machen */
:root[data-theme="dark"] body input:-webkit-autofill,
:root[data-theme="dark"] body input:-webkit-autofill:hover,
:root[data-theme="dark"] body input:-webkit-autofill:focus,
:root[data-theme="dark"] body textarea:-webkit-autofill,
:root[data-theme="dark"] body select:-webkit-autofill{
  -webkit-text-fill-color:var(--text)!important;
  caret-color:#ffffff;
  -webkit-box-shadow:0 0 0 1000px var(--card-soft) inset!important;
  box-shadow:0 0 0 1000px var(--card-soft) inset!important;
  border-color:var(--line-strong)!important;
  transition:background-color 9999s ease-out 0s;
}

/* Visueller Editor */
:root[data-theme="dark"] .rich-editor,
:root[data-theme="dark"] .rich-editor-content,
:root[data-theme="dark"] .rich-editor-toolbar{
  color:var(--text)!important;
  background:var(--card-soft)!important;
  border-color:var(--line)!important;
}

:root[data-theme="dark"] .rich-editor-toolbar button{
  color:var(--muted-strong)!important;
  background:var(--card)!important;
  border-color:var(--line)!important;
}

:root[data-theme="dark"] .rich-editor-toolbar button:hover,
:root[data-theme="dark"] .rich-editor-toolbar button.active{
  color:var(--ink)!important;
  background:var(--surface-hover)!important;
}

/* Alter und neuer Supportbereich: keine weißen Nachrichtenkarten mehr */
:root[data-theme="dark"] .support-thread{
  color:var(--text);
  background:transparent!important;
}

:root[data-theme="dark"] .support-message{
  color:var(--text)!important;
  background:var(--card-soft)!important;
  border-color:var(--line-strong)!important;
}

:root[data-theme="dark"] .support-message.internal{
  background:rgba(245,158,11,.10)!important;
  border-color:rgba(245,158,11,.28)!important;
}

:root[data-theme="dark"] .support-message strong,
:root[data-theme="dark"] .support-message p{
  color:var(--text)!important;
}

:root[data-theme="dark"] .support-message small{
  color:var(--muted)!important;
}

/* Ausgewähltes Ticket links bleibt dunkel und gut lesbar */
:root[data-theme="dark"] .support-admin-ticket-list .list-link{
  color:var(--text)!important;
  background:transparent;
}

:root[data-theme="dark"] .support-admin-ticket-list .list-link:hover{
  color:var(--ink)!important;
  background:var(--surface-hover)!important;
}

:root[data-theme="dark"] .support-admin-ticket-list .list-link.active{
  color:var(--ink)!important;
  background:color-mix(in srgb,var(--blue) 15%,var(--card))!important;
  border:1px solid color-mix(in srgb,var(--blue) 35%,var(--line))!important;
}

:root[data-theme="dark"] .support-admin-ticket-list .list-link span,
:root[data-theme="dark"] .support-admin-ticket-list .list-link.active span{
  color:var(--muted)!important;
}

/* Neuer Live-Support */
:root[data-theme="dark"] .support-live-thread{
  background:var(--card-soft)!important;
}

:root[data-theme="dark"] .support-live-message{
  color:var(--text)!important;
  background:var(--card)!important;
  border-color:var(--line-strong)!important;
}

:root[data-theme="dark"] .support-live-message p,
:root[data-theme="dark"] .support-live-message strong{
  color:var(--text)!important;
}

/* Browser-eigene Suchfelder und sonstige direkte Admin-Eingaben */
:root[data-theme="dark"] .search-form input,
:root[data-theme="dark"] .inline-form input,
:root[data-theme="dark"] .inline-form select,
:root[data-theme="dark"] .admin-content input,
:root[data-theme="dark"] .admin-content select,
:root[data-theme="dark"] .admin-content textarea{
  color:var(--text)!important;
}

/* Textauswahl bleibt auch auf dunklen Nachrichten lesbar */
:root[data-theme="dark"] ::selection{
  color:#ffffff;
  background:rgba(47,117,255,.58);
}


/* StudiAI 6.5.9 – Uploadbereich im Darkmode */
:root[data-theme="dark"] .upload-zone{
  color:var(--text)!important;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb,var(--card-soft) 92%,#000 8%),
      var(--card-soft)
    )!important;
  border-color:var(--line-strong)!important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.025),
    0 10px 28px rgba(0,0,0,.10);
}

:root[data-theme="dark"] .upload-zone:hover,
:root[data-theme="dark"] .upload-zone:focus-within{
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb,var(--card-soft) 86%,var(--blue) 14%),
      var(--card-soft)
    )!important;
  border-color:#568df0!important;
}

:root[data-theme="dark"] .upload-zone strong{
  color:var(--ink)!important;
}

:root[data-theme="dark"] .upload-zone .muted,
:root[data-theme="dark"] .upload-zone p{
  color:var(--muted)!important;
}

:root[data-theme="dark"] .upload-zone input[type="file"]{
  display:block;
  width:min(100%,630px);
  margin:16px auto 0;
  padding:8px;
  color:var(--muted-strong)!important;
  -webkit-text-fill-color:var(--muted-strong);
  background:var(--card)!important;
  border:1px solid var(--line-strong)!important;
  border-radius:12px;
}

:root[data-theme="dark"] .upload-zone input[type="file"]::file-selector-button{
  min-height:42px;
  margin-right:12px;
  padding:9px 16px;
  border:1px solid var(--line-strong);
  border-radius:10px;
  color:var(--ink);
  background:var(--surface-hover);
  font-weight:750;
}

:root[data-theme="dark"] .upload-zone input[type="file"]::file-selector-button:hover{
  color:#ffffff;
  background:var(--blue);
  border-color:var(--blue);
}

/* Bereits hochgeladene Dokumente dürfen ebenfalls nicht weiß erscheinen */
:root[data-theme="dark"] .document-row{
  color:var(--text)!important;
  background:var(--card)!important;
  border-color:var(--line)!important;
}

:root[data-theme="dark"] .document-row strong{
  color:var(--ink)!important;
}

:root[data-theme="dark"] .document-row .muted{
  color:var(--muted)!important;
}
