/* Globales Admin-Styling (für Django admin change-forms)
   Ziel: allgemeine, projektweite Regeln für Inputs, Selects, Labels, Buttons, Inlines, Help-Text, Errors.
   Diese Regeln sind bewusst allgemein gehalten und sollten auf allen Admin-Change-Forms wirken.
   Entferne die Test-Hervorhebungen (z. B. outline/background) nach dem Verifizieren.
*/

/* Utility-Klassen: drei feste Breiten (Small / Medium / Large) */
.change-form input.input-w-extra-small,
.change-form select.input-w-extra-small,
.change-form textarea.input-w-extra-small {
  width: 200px !important;
  max-width: 10% !important;
}

.change-form input.input-w-small,
.change-form select.input-w-small,
.change-form textarea.input-w-small {
  width: 220px !important;
  max-width: 33% !important;
}

.change-form input.input-w-medium,
.change-form select.input-w-medium,
.change-form textarea.input-w-medium {
  width: 420px !important;
  max-width: 100% !important;
}

.change-form input.input-w-large,
.change-form select.input-w-large,
.change-form textarea.input-w-large {
  width: 760px !important;
  max-width: 100% !important;
}

/* Responsive: auf kleinen Bildschirmen immer full width */
@media (max-width: 900px) {
  .change-form input.input-w-small,
  .change-form input.input-w-medium,
  .change-form input.input-w-large,
  .change-form select.input-w-small,
  .change-form select.input-w-medium,
  .change-form select.input-w-large,
  .change-form textarea.input-w-small,
  .change-form textarea.input-w-medium,
  .change-form textarea.input-w-large {
    width: 100% !important;
  }
}


/* ===== Admin-Change-Form Scope =====
   bindet nur auf Admin-Seiten mit change-form (schont Login/Index-Seiten etwas) */
.change-form,
form#company_form,
.form-horizontal {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* ===== Inputs / Selects / Textareas ===== */
.change-form input[type="text"],
.change-form input[type="number"],
.change-form input[type="email"],
.change-form input[type="url"],
.change-form textarea,
.change-form select,
.change-form input.vTextField,
.change-form input.vIntegerField,
.change-form textarea.vLargeTextField {
  display: block;
  width: 100%;                 /* volle Breite innerhalb des Feld-Containers */
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.375rem 0.5rem;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  background: #fff;
  transition: border-color .12s ease, box-shadow .12s ease;
  font-size: 0.95rem;
  line-height: 1.3;
}

/* Fokus: sichtbarer, aber dezent */
.change-form input:focus,
.change-form textarea:focus,
.change-form select:focus {
  outline: 0;
  border-color: #6ea8fe;
  background-color: lightyellow;
  box-shadow: 0 0 0 0.15rem rgba(13,110,253,0.12);
}

/* ===== Labels & Layout ===== */
.change-form .form-row label,
.change-form label {
  display: inline-block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: #222;
  font-size: 0.95rem;
}

/* Flex-container in Django Admin (Label + Control in einer Zeile) */
.change-form .flex-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Label-Shrink: Labels leichter, Inputs können flexibel wachsen */
.change-form .flex-container > label {
  flex: 0 0 220px; /* Label-Basisbreite; anpassen falls nötig */
  max-width: 35%;
  min-width: 140px;
  text-align: left;
}

/* Input-Container nimmt Rest */
.change-form .flex-container > *:not(label) {
  flex: 1 1 auto;
  min-width: 180px;
}

/* ===== Related widgets (ForeignKey select + "add" buttons) ===== */
.related-widget-wrapper,
.related-widget-wrapper .related-widget {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.related-widget-wrapper select {
  flex: 1 1 auto;
  min-width: 180px;
}

/* Buttons neben selects (Add/Change) etwas kleiner & einheitlich */
.related-widget-wrapper .addlink,
.related-widget-wrapper .related-lookup,
.related-widget-wrapper .change-related,
.related-widget-wrapper .vManyToManyRawIdAdminField + a {
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
  border-radius: 4px;
}

/* ===== Help-Text / Errors ===== */
.change-form .help,
.change-form .form-text,
.change-form .helptext {
  color: red;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.change-form .errorlist {
  color: #b00020;
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}

/* Field-Level error: make input border red */
.form-row .errors ~ input,
.form-row .errors ~ textarea,
.form-row .errors ~ select,
.form-row .errors input,
.form-row .errors textarea,
.form-row .errors select {
  border-color: #d93025;
  box-shadow: 0 0 0 0.12rem rgba(217, 48, 37, 0.08);
}

/* ===== Buttons / Submit-Row ===== */
.submit-row .button,
object-tools .button,
a.button {
  background: #0d6efd;
  color: #fff;
  border: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}
input[type="submit"].default, .submit-row .default {
  background: #198754;
}

/* ===== Inline related blocks (inlines) ===== */
.inline-related {
  border-top: 1px dashed #e6e6e6;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

/* ===== Responsive tweaks ===== */
@media (max-width: 900px) {
  .change-form .flex-container > label {
    flex-basis: 100%;
    max-width: 100%;
  }
  .change-form .flex-container > *:not(label) {
    flex-basis: 100%;
  }
}

/* ===== Accessibility / focus-visible fallback ===== */
:focus:not(:focus-visible) { box-shadow: none; }

/* ===== Utility: make admin link-buttons stand out (e.g. website link) ===== */
a#website-link-admin,
a[id^="website-link-"] {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  background: transparent;
  color: #0d6efd;
  text-decoration: none;
  font-weight: 600;
}


/* === vDateField / vTimeField - compact & aligned styling for Django Admin === */

/* Standardgröße für Datum- und Zeitfelder */
.change-form input.vDateField,
.change-form input.vTimeField,
.change-form input[type="date"],
.change-form input[type="time"] {
  display: inline-block;
  width: 180px;          /* Standardbreite für Datum-Feld */
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.32rem 0.45rem;
  font-size: 0.95rem;
  line-height: 1.2;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  background: #fff;
}

/* Wenn Datum+Zeit in <p class="datetime"> gerendert werden, kleinere Time-Input */
.change-form p.datetime input.vDateField {
  width: 200px;          /* Datum etwas breiter */
}
.change-form p.datetime input.vTimeField {
  width: 200px;          /* Zeit kurz (hh:mm) */
}

/* Support für native date/time inputs */
.change-form input[type="date"] {
  width: 200px;
}
.change-form input[type="time"] {
  width: 110px;
}

/* Fokuszustand (passend zu globalem Fokus-Look) */
.change-form input.vDateField:focus,
.change-form input.vTimeField:focus,
.change-form input[type="date"]:focus,
.change-form input[type="time"]:focus {
  outline: 0;
  border-color: #6ea8fe;
  box-shadow: 0 0 0 0.12rem rgba(13,110,253,0.10);
}

/* Kleinere Darstellung in sehr engen Layouts / mobile */
@media (max-width: 900px) {
  .change-form input.vDateField,
  .change-form input.vTimeField,
  .change-form input[type="date"],
  .change-form input[type="time"] {
    width: 100% !important;
  }
}

/* Optional: wenn du explizit sehr kompakte Datum-Felder willst, 
   kannst du .vDateField.small verwenden (siehe Hinweise weiter unten) */
.change-form input.vDateField.small {
  width: 100px !important;
}


/* falls du Breiten für Input-Wrapper willst (z.B. Textinputs) */
.vTextField.input-w-small { width: 12rem; }


.change-form .help {
  color: #193342 !important; /* hier wirkt es! */
  font-style: italic;
  text-align: left;
}




/* === Einheitliche Label‑Spalte, speziell für Checkbox‑Labels ===
   Label-Breite zentral steuern und Checkbox-Labels auf dieselbe Breite bringen.
*/
:root {
  /* passe diese Breite an (z. B. 12rem oder 14rem) */
  --label-width: 16rem;
}

/* Falls noch keine feste Label-Spalte gesetzt ist, setze sie (Desktop) */
.change-form .form-row > div > div label {
  flex: 0 0 var(--label-width);
  max-width: var(--label-width);
  box-sizing: border-box;
  text-align: left;
  margin: 0;
}

/* Checkbox-Labels: dieselbe Label-Spalte verwenden */
.change-form .flex-container.checkbox-row .vCheckboxLabel,
.inline-related .flex-container.checkbox-row .vCheckboxLabel {
  flex: 0 0 var(--label-width);
  max-width: var(--label-width);
  text-align: left;    /* sicherstellen linksbündig */
  margin: 0;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Checkbox selbst: kompakt und rechts vom Label */
.change-form .flex-container.checkbox-row input[type="checkbox"],
.inline-related .flex-container.checkbox-row input[type="checkbox"] {
  order: 1;
  flex: 0 0 auto;
  margin-left: 0.5rem;
  text-align: left;
}

/* Responsive: auf kleinen Bildschirmen kein festes Label-Layout */
@media (max-width: 900px) {
  .change-form .form-row > div > div { display: block; }
  .change-form .form-row > div > div label { display: block; margin-bottom: .25rem; }
  .change-form .flex-container.checkbox-row .vCheckboxLabel,
  .inline-related .flex-container.checkbox-row .vCheckboxLabel {
    flex: 0 0 auto;
    max-width: none;
    display: block;
    margin-bottom: .25rem;
  }
}



/* static/css/admin_custom.css */

/* Fieldset / Section Hintergrund */
fieldset.module {
  background: #8ae2ff45;              
  border: 1px solid #c8e6c9;       /* dezente Umrandung */
  padding: 12px 16px 16px 16px;
  margin-bottom: 18px;
  border-radius: 6px;
}

/* Titelzeile der Section */
fieldset.module h2 {
  background: darkblue;             /* dunkleres Grün */
  color: #fff;
  margin: -12px -16px 12px -16px;  /* Titel über den Fieldset-Rand ziehen */
  padding: 8px 12px;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  font-weight: 600;
}

/* Falls Fieldset collapsed ist (eingeklappt) */
fieldset.module.collapse h2 {
  background: #4545b7;
}

/* Inhalt ein wenig Abstände geben */
fieldset.module .form-row, fieldset.module .form-row .field-box {
  margin-bottom: 8px;
}

/* Inline-Gruppen (z.B. Inlines) */
.inline-group {
  background: #f1f8f2;
  border: 1px solid #dcedc8;
  padding: 10px;
  border-radius: 6px;
}


/* make the "last_company_id" field compact on the Company admin page */
body.app-companies.model-company .change-form #id_last_company_id,
body.app-companies.model-company .change-form input[name="last_company_id"],
body.app-companies.model-company .change-form textarea#id_last_company_id {
  width: 6.5rem !important;     /* gewünschte Breite (anpassen) */
  max-width: 6.5rem !important;
  display: inline-block;
}


/* 1) Minimal / dezent (Standard) */
.changelist-subtitle {
  margin-top: 0.35rem;
  margin-bottom: 0.6rem;
  color: red;                 /* dezenter Grauton */
  font-size: 0.95rem;
  line-height: 1.35;
}

/* End of admin_custom.css */
