/* --- 1. Globale Einstellungen und Haupt-Container --- */

body {
    background-color: #f4f4f4; /* Leichter Hintergrund */
    font-family: Arial, sans-serif;
    color: #333;
    margin: 0;
    padding: 0;
}

h2 {
    color: #0056b3;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

/* Container-Begrenzung für große Bildschirme */
#warenkorb_container {
    max-width: 1200px; /* Maximale Breite des Warenkorbbereichs */
    width: 90%; /* Nimmt 90% der verfügbaren Breite ein */
    margin: 20px auto; /* Zentriert den Container horizontal */
}

/* --- 2. Struktur der Warenkorb-Elemente (Desktop-Layout) --- */

.warenkorb-element {
    /*display: flex;*/
    /*display: grid;
    grid-auto-flow: column;
    grid-template-columns: auto 1fr auto;*/
    display: grid;

    /* 1. KORREKTUR: Definiere ZWEI Spalten */
    grid-template-columns: 1fr 3fr;

    /* 2. KORREKTUR: Nur ZWEI Zeilen (x, dann m/n) */
    grid-template-rows: auto auto;

    /* 3. KORREKTUR: Die dritte Zeile entfernen, wenn nicht belegt */
    grid-template-areas:
            "x x"
            "m n";

    /* Empfehlung: Fügen Sie eine Lücke hinzu, um Abstände zu kontrollieren */
    /*gap: 1rem;
    padding: 1rem;*/


    align-items: center; /* Vertikal zentrieren */
    padding: 15px; /* Einheitlicher Innenabstand */
    margin-bottom: 15px;
    gap: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Deutlicherer Schatten */
    transition: transform 0.2s;
    min-height: 140px;
}

.warenkorb-element-infos-container {
    grid-area: n;
}

.warenkorb-element-infos {

    display: flex;
    align-items: center; /* Vertikal zentrieren */
    justify-content: flex-end; /* Vertikal zentrieren */
    /* Einheitlicher Innenabstand */
    padding: 15px 0;
    margin-bottom: 15px;
    gap: 20px;
    transition: transform 0.2s;
    /*width: 100%;*/
}

.warenkorb-element:hover {
    transform: translateY(-2px); /* Leichter Schwebe-Effekt */
}

/* Titel des Artikels */
.warenkorb-element h3 {
    grid-area: x;
    flex-basis: 100%;
    max-width: 100%;
    margin: 0;
    font-size: 1.1em;
    color: #0056b3;
    font-weight: 600;
    border-bottom: 1px solid #eee;
}

/* --- 3. Bild und Preis-Spalten --- */

.warenkorb-element-bild {
    flex-basis: 120px; /* Fixe Bildhöhe */
    height: 120px; /* erzwingt gleich hohe Spalte */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- 3. Bild und Preis-Spalten --- */

.warenkorb-element-bild {
    grid-area: m;
    flex-basis: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.warenkorb-element-bild img {
    max-width: 90%;
    max-height: 100%;
    width: 100%; /* skaliert innerhalb max-width */
    height: auto;
    object-fit: scale-down; /* Bild bleibt proportional */
    border-radius: 6px;
    display: block;
}

.warenkorb-element-stueckpreis,
.warenkorb-element-totalpreis {
    flex-basis: 15%;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    color: #333;
}

/* Totalpreis hervorheben */
.warenkorb-element-totalpreis {
    color: #D35400; /* Orange für den Gesamtpreis */
}


/* --- 4. Anzahl-Input (Aufgehübscht) --- */

.warenkorb-element-anzahl {
    flex-basis: 15%;
    text-align: center;
}

.warenkorb-element-anzahl-input {
    width: 60px;
    padding: 8px 10px;
    border: 2px solid #ccc;
    border-radius: 6px;
    text-align: center;
    font-size: 1em;
    -moz-appearance: textfield; /* Firefox hides controls */
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* Versteckt die Pfeile für Webkit (Chrome, Safari) */
.warenkorb-element-anzahl-input::-webkit-outer-spin-button,
.warenkorb-element-anzahl-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.warenkorb-element-anzahl-input:focus {
    border-color: #0056b3;
    box-shadow: 0 0 5px rgba(0, 86, 179, 0.5);
    outline: none;
}


/* --- 5. Entfernen-Button --- */

.warenkorb_element_entfernen {
    flex-basis: 15%;
    text-align: right;
    padding-right: 15px;
}

.warenkorb_element_entfernen_button {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s;
}

.warenkorb_element_entfernen_button:hover {
    background-color: #c82333;
}


/* --- 6. Bestell-Button unten --- */

#warenkorb_bestellen_div, #warenkorb_bestellen_leer_div {
    max-width: 1200px;
    width: 90%;
    margin: 20px auto;
    display: flex;
    justify-content: flex-end;
    padding: 20px 0;
    border-top: 2px solid #ddd;
}

#warenkorb_bestellen_leer_div {
    justify-content: center;
}

#warenkorb_bestellen_btn, #warenkorb_zum_sortiment_button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
}


#warenkorb_bestellen_btn:hover {
    background-color: #45a049;
}

/* Die HR-Linie aus dem HTML kann entfernt werden oder ausgeblendet werden */
hr {
    display: none;
}

/* ========================================================== */
/* --- 7. Media Queries für Mobilgeräte (Responsive Design) --- */
/* ========================================================== */

@media (max-width: 800px) {
    /* Alle Elemente im Container sollen die volle Breite nutzen */
    #warenkorb_container,
    #warenkorb_bestellen_div {
        width: 95%; /* Etwas mehr Platz auf kleinen Geräten */
        margin: 10px auto;
    }

    .warenkorb-element {
        /* Ändern von horizontaler Flexbox zu vertikalem Layout */
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
        gap: 10px;
    }

    .warenkorb-element-infos {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
        gap: 10px;
    }

    .warenkorb-element h3 {
        /* Titel oben, volle Breite */
        flex-basis: auto;
        padding-left: 0;
        font-size: 1.2em;
        width: 100%;
        text-align: left;
        border-bottom: 1px solid #eee;
        padding-bottom: 5px;
    }

    .warenkorb-element-bild img {
        width: 100px; /* Bild im mobilen Modus größer */
    }

    /* Hilfs-Container für Preis und Anzahl (horizontal in mobiler Ansicht) */
    .warenkorb-details-row {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 5px 0;
    }

    /* Die einzelnen Spalten werden jetzt im Details-Row flexibel angeordnet */
    .warenkorb-element-stueckpreis,
    .warenkorb-element-totalpreis,
    .warenkorb-element-anzahl,
    .warenkorb_element_entfernen {
        flex-basis: 33%;
        text-align: center;
        padding: 0;
        width: auto;
    }

    /* Entfernen-Button in eigener Zeile unten links */
    .warenkorb_element_entfernen {
        flex-basis: 100%;
        text-align: left;
        padding-right: 0;
    }

    /* Beschriftung für bessere Verständlichkeit im mobilen Modus */
    .warenkorb-element-stueckpreis::before {
        content: "Preis/Stück: ";
        font-weight: normal;
        display: block;
        font-size: 0.8em;
        color: #666;
    }

    .warenkorb-element-totalpreis::before {
        content: "Gesamt: ";
        font-weight: normal;
        display: block;
        font-size: 0.8em;
        color: #666;
    }

    .warenkorb-element-anzahl label {
        display: block;
        font-size: 0.8em;
        color: #666;
        margin-bottom: 3px;
    }
}

/* ================================ */
/*  Gesamtsumme über dem Button     */
/* ================================ */

#warenkorb_bestellen_div {
    max-width: 1200px;
    width: 90%;
    margin: 40px auto; /* mehr Abstand nach oben */
    display: flex;
    flex-direction: column; /* Inhalte untereinander */
    align-items: center; /* zentriert */
    gap: 18px; /* Abstand zwischen Text & Button */
    padding: 25px 0;
    border-top: 2px solid #ddd;
}

#warenkorb_gesamtpreis_anzeige {
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    text-align: center;
    background: #ffffff;
    padding: 10px 18px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

#warenkorb_leer {
    font-size: 1.2rem;
    color: #666;
    text-align: center;
    margin-top: 10px;
}

#warenkorb_leer_p {
    font-size: 1.2rem;
    color: #666;
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
}

@media (max-width: 800px) {
    .warenkorb-element {
        display: grid;

        /* 1. KORREKTUR: Definiere ZWEI Spalten */
        grid-template-columns: 1fr 1fr;

        /* 2. KORREKTUR: Nur ZWEI Zeilen (x, dann m/n) */
        grid-template-rows: auto auto;

        /* 3. KORREKTUR: Die dritte Zeile entfernen, wenn nicht belegt */
        grid-template-areas:
            "x x"
            "m n";

        /* Empfehlung: Fügen Sie eine Lücke hinzu, um Abstände zu kontrollieren */
        gap: 1rem;
        padding: 1rem;
    }

    .warenkorb-element h3 {
        grid-area: x;
        flex-basis: 100%;
        max-width: 100%;
        margin: 0;
        font-size: 1.1em;
        color: #0056b3;
        font-weight: 600;
    }

    /*.warenkorb-element-name {
        grid-area: x;
        width: 500px;
        display: block;
        text-align: center;
    }*/
    .warenkorb-element-bild {
        grid-area: m;
        width: 100%;
        height: 100%;
        display: flex;
    }

    .warenkorb-element-stueckpreis,
    .warenkorb-element-totalpreis,
    .warenkorb-element-anzahl,
    .warenkorb_element_entfernen {
        flex-basis: 33%;
        text-align: center;
        padding: 0;
        max-width: 100px;
    }

    .warenkorb-element-infos-container {

        display: flex;
        align-items: center;
        justify-content: center;
    }

    .warenkorb-element-infos {
        overflow-x: hidden;
        grid-area: n;
        display: flex;
        padding: 0;
    }

    .warenkorb-element-bild img {
        max-width: 90%;
        max-height: 20svh;
        width: 100%; /* skaliert innerhalb max-width */
        height: auto;
        object-fit: contain; /* Bild bleibt proportional */
        border-radius: 6px;
        display: block;
    }
}