/* Tabellen-Layout */
#main .flex-container {
    display: flex;
    gap: 2em;
    flex-wrap: wrap;
    justify-content: center;
}

#main .flex-container > table {
    flex: 1;
    min-width: auto;
    max-width: auto;
}

#main table {
    width: auto;
    margin: 1em auto;
    border-collapse: collapse;
}

/* Tabellen-Zellen */
#main table th,
#main table td {
    padding: 0.5em 1em;
    border: 1px solid #ddd;
    text-align: left;
    white-space: nowrap;
    font-size: 0.9em;
    font-family: Arial, sans-serif;
}

#main table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

#main table td:last-child {
    text-align: right;
}

/* Input-Felder */
#main table input,
#main table select {
    width: 100%;
    padding: 0.5em;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: Arial, sans-serif;
}

/* Readonly-Felder */
#main table input[readonly] {
    background-color: #f5f5f5;
    color: #666;
    font-weight: normal;
}

/* Editierbare Felder */
#main table input:not([readonly]) {
    background-color: #ffffff;
    color: #000;
    font-weight: normal;
    border: 2px solid #000;
}

#main table strong {
    font-family: inherit;
    font-weight: bold;
}

/* Überschriften */
#main h3 {
    text-align: center;
}

/* Fieldset */
#main fieldset {
    border: 2px solid #ddd;
    padding: 2em;
    border-radius: 8px;
}

#main legend {
    padding: 0 1em;
    font-weight: bold;
}

/* Debug-Block */
#main .debug-block {
    background: #fffacd;
    padding: 1em;
    margin: 1em 0;
    border: 2px solid #ffd700;
    border-radius: 5px;
}

/* Buttons */
#main button {
    padding: 0.8em 2em;
    margin: 0.5em;
    cursor: pointer;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
}

#main button:hover {
    background: #555;
}

#toggleDebug {
    width: auto !important;
    height: auto !important;
    display: inline-block !important;
    margin-right: 8px;
    cursor: pointer;
}

.bauweise-box {
    border: 2px solid #ddd;
    padding: 1em;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.bauweise-box:hover {
    border-color: #999;
    background: #f9f9f9;
}

input[type="radio"]:checked + .bauweise-box {
    border-color: #4CAF50;
    background: #e8f5e9;
}

/* Checkboxen und Radio-Buttons normale Größe */
#main table input[type="checkbox"],
#main table input[type="radio"] {
    width: auto !important;
    display: inline-block;
    margin-right: 0.5em;
    vertical-align: middle;
}

/* Labels mit Checkboxen */
#main table label {
    display: inline-block;
    cursor: pointer;
}

/* Checkboxen sichtbar machen */
#main table input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    display: inline-block;
    margin-right: 0.5em;
    vertical-align: middle;
    cursor: pointer;
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
}

#main table input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    display: inline-block;
    margin-right: 0.5em;
    vertical-align: middle;
    cursor: pointer;
    -webkit-appearance: radio !important;
    -moz-appearance: radio !important;
    appearance: radio !important;
}

/* Mobile Optimierung - passt sich dem Screen an */
@media screen and (max-width: 768px), 
       (max-height: 768px) and (orientation: landscape) {
    /* Bauweise-Boxen auf Mobile kleiner und untereinander */
    .bauweise-box {
        width: 180px !important;
        height: 220px !important;
    }
    
    .bauweise-box img {
        width: 120px !important;
        height: 100px !important;
    }
    
    .bauweise-box p {
        font-size: 0.85em;
    }
    
    /* Container für Bauweise - untereinander statt nebeneinander */
    h3 + div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: center !important;
    }

    .flex-container {
        flex-direction: column;
    }
    
    /* Tabelle nutzt volle Breite */
    #main table {
        width: 100%;
        font-size: 0.9em;
    }
    
    /* Zellen kompakter */
    #main table td,
    #main table th {
        padding: 0.3em 0.3em;
        font-size: 0.9em;
    }
    
    /* Input-Felder passen sich an */
    #main table input,
    #main table select {
        width: 100%;
        padding: 0.3em;
        font-size: 0.9em;
        box-sizing: border-box;
    }
    
    /* Labels etwas kleiner */
    #main table td:first-child {
        font-size: 0.8em;
    }
    
    /* Fieldset-Padding reduzieren */
    #main fieldset {
        padding: 1em 0.5em;
    }

    /* Grid NUR für Eingabeformular */
    fieldset#all > form table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5em;
        border-bottom: 1px solid #ddd;
        padding: 0.5em 0;
    }
    
    fieldset#all > form table td {
        border: none;
    }
    
    /* Canvas max height */
    #sparrenCanvas {
        width: 100%;
        height: 100%;
    }
    
/* Kopfbänder-Zeilen komplett raus aus Grid - als volle Breite */
    #kopfband_einfahrt,
    #kopfband_hinten,
    #kopfband_links,
    #kopfband_rechts {
        display: none !important; /* Default versteckt */
    }
    
    /* Wenn sichtbar: komplette Zeile nutzen, kein Grid! */
    #kopfband_einfahrt[style*="table-row"],
    #kopfband_hinten[style*="table-row"],
    #kopfband_links[style*="table-row"],
    #kopfband_rechts[style*="table-row"] {
        display: block !important;
        grid-column: 1 / -1 !important; /* Nutzt beide Grid-Spalten */
        width: 100% !important;
        padding: 0.5em 1em !important;
        box-sizing: border-box !important;
    }
    
    /* Alle td's darin als Block */
    #kopfband_einfahrt td,
    #kopfband_hinten td,
    #kopfband_links td,
    #kopfband_rechts td {
        display: block !important;
        width: 100% !important;
        padding: 0.3em 0 !important;
        border: none !important;
        box-sizing: border-box !important;
    }
    
    /* Input-Felder auf 90% begrenzen */
    #kopfband_einfahrt input,
    #kopfband_hinten input,
    #kopfband_links input,
    #kopfband_rechts input {
        width: 100% !important;
        max-width: 300px !important;
        box-sizing: border-box !important;
    }
}
