/* Mobile Optimierungen für CAV Webseite */
/* Fügen Sie diesen Code am Ende Ihrer cav.css Datei hinzu oder erstellen Sie eine separate mobile.css */

/* Basis-Verbesserungen für alle Geräte */
body {
    min-width: 320px; /* Statt 300px */
}

/* Verbesserte Touch-Targets */
#avmenu > ul > li > a {
    min-height: 44px; /* Mindestgröße für Touch-Targets */
    padding: 12px 8px;
    line-height: 1.4;
}

/* Tablet-Ansicht (600px - 900px) */
@media screen and (max-width: 900px) and (min-width: 601px) {
    body {
        font-size: 0.875em; /* Statt variabel */
        padding-left: 1em;
        padding-right: 1em;
    }
    
    #avmenu > ul > li {
        min-width: 120px;
    }
    
    #avmenu > ul > li > a {
        font-size: 0.9em;
        padding: 12px 6px;
    }
}

/* Mobile Ansicht (unter 600px) - HAUPTVERBESSERUNGEN */
@media screen and (max-width: 600px) {
    body {
        font-size: 0.875em; /* Konsistente Größe statt 0.625em */
        padding: 0;
    }
    
    /* Header-Optimierung */
    #header {
        height: auto;
        min-height: 60px;
        padding: 1em 1em 0.5em 1em;
    }
    
    #dialog {
        height: 3em;
        width: auto;
        margin-left: 0;
    }
    
    #cav-logo {
        margin-top: 0.5em;
    }
    
    #cav-logo img:last-child {
        height: 40px;
        margin-right: 1em;
    }
    
    /* Menü-Verbesserungen */
    #avmenu {
        padding: 0;
        font-size: 1em; /* Statt 1.25em */
    }
    
    #avmenu > ul {
        width: 100%;
        border: none;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #avmenu > ul > li {
        flex: 1 1 auto;
        min-width: 100px;
        max-width: 50%; /* Maximal 2 pro Zeile auf sehr kleinen Screens */
        border: 1px solid rgba(255,255,255,.15);
    }
    
    #avmenu > ul > li > a {
        height: auto;
        min-height: 44px;
        padding: 12px 8px;
        font-size: 0.95em;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1.3;
    }
    
    /* Dropdown-Menü für Mobile */
    #avmenu li a + ul {
        position: relative;
        width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
    }
    
    #avmenu li a.active + ul,
    #avmenu li a:focus + ul {
        display: block;
    }
    
    #avmenu li ul li {
        height: auto;
        min-height: 44px;
    }
    
    #avmenu li ul li a {
        padding: 12px 1em;
        font-size: 0.9em;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Content-Optimierung */
    #contentwide {
        padding: 1em;
        margin: 0;
        border-radius: 0;
    }
    
    #contentwide h2 {
        font-size: 1.5em;
        margin-bottom: 0.75em;
    }
    
    #contentwide h3 {
        font-size: 1.25em;
        margin-bottom: 0.75em;
    }
    
    #contentwide p {
        line-height: 1.6;
        margin-bottom: 1em;
    }
    
    /* Bilder responsive machen */
    #contentwide img {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Tabellen scrollbar machen */
    #contentwide table {
        display: block;
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Formulare */
    form {
        padding: 1em;
    }
    
    form input[type="text"],
    form input[type="password"] {
        max-width: 100%;
        font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
    }
    
    form input[type="submit"],
    form input[type="reset"],
    button {
        min-width: auto;
        width: 100%;
        max-width: 200px;
        padding: 12px;
        margin-bottom: 0.5em;
    }
    
    /* Download-Bereiche */
    div.download-wrap {
        width: 100% !important;
        margin-right: 0;
        margin-bottom: 1.5em;
        padding-bottom: 1.5em;
        border-bottom: 1px solid #eee;
    }
    
    div.download-wrap div.tile-img-wrap {
        width: 40% !important;
        max-width: 150px !important;
        margin-right: 1em;
        float: left;
    }
    
    /* Footer */
    #footer {
        padding: 1em;
        font-size: 0.9em;
    }
}

/* Sehr kleine Smartphones (unter 400px) */
@media screen and (max-width: 400px) {
    #avmenu > ul > li {
        min-width: 90px;
    }
    
    #avmenu > ul > li > a {
        font-size: 0.85em;
        padding: 10px 4px;
    }
    
    #contentwide {
        padding: 0.75em;
    }
    
    #contentwide h2 {
        font-size: 1.3em;
    }
}

/* iPhone SE und ähnliche (320px) */
@media screen and (max-width: 360px) {
    #avmenu > ul > li {
        flex: 1 1 50%;
        max-width: 50%;
    }
    
    #dialog {
        height: 2.5em;
    }
}

/* Landscape-Modus für Smartphones */
@media screen and (max-width: 900px) and (orientation: landscape) {
    #header {
        padding: 0.75em 1em 0.5em 1em;
    }
    
    #dialog {
        height: 2.5em;
    }
    
    #cav-logo img:last-child {
        height: 30px;
    }
    
    #avmenu > ul > li > a {
        padding: 8px 6px;
        min-height: 40px;
    }
}

/* Fix für die überschriebenen Smartphone-Styles */
@media only screen and (max-device-width: 480px),
       only screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2),
       only screen and (max-width: 320px) and (max-device-width: 800px) {
    body {
        font-size: 0.875em; /* Statt 2.0em - viel zu groß! */
    }
}

/* Verbesserte Touch-Interaktionen */
@media (hover: none) and (pointer: coarse) {
    /* Für Touch-Geräte */
    #avmenu > ul > li > a {
        -webkit-tap-highlight-color: rgba(237,154,71,0.3);
    }
    
    #avmenu li a + ul {
        display: none;
    }
    
    /* Toggle-Funktionalität mit Checkbox-Hack */
    #avmenu input[type="checkbox"] {
        display: none;
    }
    
    #avmenu input[type="checkbox"]:checked + ul {
        display: block !important;
    }
}