/*
 * MWFewoManager
 *
 * @author Küstenweb GmbH <info@mwfewomanager.de>
 * @copyright mwfewomanager.de
 */

/* --------------------------------------------------
   Modern Reset (lightweight, framework-like)
-------------------------------------------------- */

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

html {
    -webkit-text-size-adjust: 100%;
    font-size: 100%; /* ensure base 16px to prevent mobile input zoom */
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-family-sans-serif);
    line-height: var(--line-height, 1.5);
    min-height: 100vh;
    text-rendering: optimizeLegibility;
}

/* Remove default margins */
h1, h2, h3, h4, h5, h6,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

/* --------------------------------------------------
   Headings – Base Typography
-------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--heading-color, var(--color-text));
    margin-bottom: .75rem;
}

h1 { font-size: var(--font-size-h1, 2rem); }
h2 { font-size: var(--font-size-h2, 1.75rem); }
h3 { font-size: var(--font-size-h3, 1.5rem); }
h4 { font-size: var(--font-size-h4, 1.25rem); }
h5 { font-size: var(--font-size-h5, 1.125rem); }
h6 { font-size: var(--font-size-h6, 1rem); }

/* Optional spacing utility for headings */

/* Abstand über Überschriften im Fließtext. In `:where()`, also ohne
   Gewicht: Ein Bauteil, das für seine Überschrift `margin: 0` setzt
   (Blatt, Leerzustand, Karte), gewinnt mit einer einzigen Klasse. Vorher
   stand die Regel mit Element plus Pseudoklasse über jeder Bauteilklasse,
   und jede Überschrift, vor der ein Zeichen oder ein Knopf stand, bekam
   2 rem Luft darüber. */
:where(h1, h2, h3, h4, h5, h6):where(:not(:first-child)) {
    margin-top: 1.5rem;
}

:where(h1, h2):where(:not(:first-child)) {
    margin-top: 2rem;
}

/* Lists without default spacing */
ul, ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Media elements */
img,
picture,
video,
canvas {
    display: block;
    max-width: 100%;
}

/* Form elements inherit font */
input,
button,
textarea,
select {
    font: inherit;
}

figure { line-height: 0; }
figcaption { line-height: var(--line-height, 1.5); }
label { margin: 0; }

/* --------------------------------------------------
   Form Controls – Base Layout (Contao)
   - 100% width for text-like controls (no checkbox/radio)
   - consistent height/border across input/select/textarea
-------------------------------------------------- */

:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ) {
    width: 100%;
    min-height: 2.5rem;

    padding: .6rem .9rem;

    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);

    background-color: var(--color-surface);
    color: var(--color-text);

    font-size: 1rem; /* prevent iOS zoom */
    line-height: 1.4;

    transition: border-color .15s ease, box-shadow .15s ease;
}

:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ):focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ):disabled {
    background-color: color-mix(in srgb, var(--color-surface) 90%, #000 5%);
    cursor: not-allowed;
    opacity: .7;
}

/* --------------------------------------------------
   Form States & Validation
-------------------------------------------------- */

:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ):focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

/* Valid */
:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ).is-valid {
    border-color: var(--color-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 20%, transparent);
}

/* Invalid */
:where(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
      textarea,
      select
    ).is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 20%, transparent);
}

/* Feedback blocks (always directly after field) */
.valid-feedback,
.invalid-feedback {
    display: block;
    font-size: .875rem;
}

.valid-feedback {
    color: var(--color-success);
}

.invalid-feedback {
    color: var(--color-danger);
}

:where(input, select, textarea).is-valid {
    border-color: var(--color-success);
    color: var(--color-success);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2'><circle cx='12' cy='12' r='10'/><path d='M9 12l2 2 4-4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    background-size: 20px;
}
:where(input, select, textarea).is-invalid {
    border-color: var(--color-danger);
    color: var(--color-danger);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2'><circle cx='12' cy='12' r='10'/><line x1='12' y1='8' x2='12' y2='13' stroke-linecap='round'/><circle cx='12' cy='17' r='1' fill='%23dc2626'/></svg>");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    background-size: 20px;
}


:where(select).is-valid,
:where(select).is-invalid {
    background-position: right 0.9rem center;
}

/* Contao form widget spacing + labels */
.formbody {
    display: grid;
    gap: 1rem;
}

form label {
    display: inline-block;
    margin-bottom: .5rem;
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.3;
    color: inherit;
    letter-spacing: .01em;
}

/* Optional required indicator spacing */
.formbody .widget > label .mandatory {
    margin-left: .25rem;
    color: var(--color-danger);
    font-weight: 600;
}

/* Improved vertical layout for form widgets */
.formbody .widget {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    position: relative;
}

/* Ensure consistent spacing between form rows */
.formbody {
    gap: 1.25rem;
}

/* Contao default field classes */
.formbody .widget input.text,
.formbody .widget textarea.textarea,
.formbody .widget select.select {
    width: 100%;
}

/* --------------------------------------------------
   Contao Checkbox / Radio Layout
-------------------------------------------------- */

.formbody .widget-checkbox .checkbox_container,
.formbody .widget-radio .radio_container {
    display: grid;
    gap: .5rem;
}

.formbody .widget-checkbox .checkbox_container span,
.formbody .widget-radio .radio_container span {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.formbody .widget-checkbox input.checkbox,
.formbody .widget-radio input.radio {
    width: auto;
    min-height: auto;
    margin: 0;
}

.formbody .widget-checkbox label,
.formbody .widget-radio label {
    margin: 0;
    font-weight: 400;
}

/* --------------------------------------------------
   Form
-------------------------------------------------- */

.form-check label { display: inline-block; }

.form-group { position: relative; display: block; width: 100%; }
.input-group { position: relative; }

/* --------------------------------------------------
   Select – Base Layout
-------------------------------------------------- */

select {
    /* keep shared control sizing from Form Controls block */
    padding-right: 2.25rem; /* space for chevron */

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 8 10 12 14 8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 14px;
}

/* Remove button defaults */
button {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

/* Anchor baseline */
a {
    color: var(--link-color, var(--color-primary));
    text-decoration: none;
}

a:hover {
    color: var(--link-hover-color, var(--color-primary-hover));
}

a.active {
    color: var(--link-hover-color, var(--color-primary-hover));
}

/* Tables */
table {
    border-collapse: collapse;
    border-spacing: 0;
}