/* public/css/mobile.css
   Zentrale Responsive-Regeln fuer alle ZENTURIS-Views.
   Wird per <link rel="stylesheet" href="/css/mobile.css"> eingebunden,
   NACH dem Inline-<style>-Block jeder Seite, damit diese Regeln bei
   Kollisionen gewinnen. Greift auf die bestehenden, seitenuebergreifend
   verwendeten Klassennamen: container, row/col, form-group, card,
   btn-*, nav-link/nav-tabs, table-responsive, modal/modal-content. */

* {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* iOS zoomt beim Fokussieren automatisch rein, wenn ein Eingabefeld
   eine Schriftgroesse unter 16px hat - das verhindert das zuverlaessig,
   unabhaengig davon was die einzelne Seite selbst festlegt. */
input, select, textarea, button {
    font-size: 16px;
}

/* Jede Tabelle bekommt automatisch horizontales Scrollen INNERHALB
   ihrer eigenen Breite, statt die ganze Seite nach rechts zu sprengen -
   auch wenn sie nicht explizit in .table-responsive eingepackt wurde. */
table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {

    body {
        font-size: 15px;
    }

    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Mehrspaltige Formularzeilen stapeln sich untereinander statt sich
       zu quetschen (siehe sa_admin.php Paket-Formular). */
    .row {
        flex-direction: column !important;
        gap: 4px !important;
    }
    .row .col,
    .row .col.form-group,
    .row > div[class*="col"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }

    .form-group {
        margin-bottom: 14px !important;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        min-height: 44px;
        padding: 10px !important;
    }

    /* Buttons brauchen auf Touch-Geraeten mehr Platz und duerfen
       umbrechen statt sich nebeneinander zu quetschen. */
    button, .btn-danger, .btn-success, .btn-warning, .btn-preset, .btn-purple, input[type="submit"] {
        min-height: 44px;
        padding: 10px 16px !important;
    }
    .container > button,
    .form-group + button,
    .row + button {
        width: 100%;
    }

    /* Navigation (Tabs/Links) horizontal scrollbar statt umbrechend -
       so bleibt sie auf einer Zeile und bedienbar. */
    .nav-tabs {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        white-space: nowrap;
    }
    .nav-tabs .tab-btn {
        flex: 0 0 auto;
    }
    .nav-link {
        display: inline-block;
        margin-bottom: 6px;
    }

    /* Karten bekommen auf Mobile volle Breite statt eines festen
       Grid-Rasters, das auf schmalen Screens nicht mehr passt. */
    .card {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Modals sollen den Bildschirm sinnvoll ausfuellen statt als
       schmales, zentriertes Fenster auf kleinem Screen zu haengen. */
    .modal-content {
        width: 92% !important;
        max-width: 92% !important;
        margin: 20px auto !important;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Feste Pixel-Breiten aus Desktop-Layouts (z.B. width: 600px in
       Inline-Styles) auf 100% herunterbrechen, damit nichts seitlich
       uebersteht. */
    [style*="width:"] {
        max-width: 100%;
    }
}

/* Tabellen mit der Klasse "responsive-cards" werden auf Mobile zu
   Karten statt zu breiten, seitlich scrollenden Tabellen. Jede Zelle
   braucht ein data-label="Spaltenname" Attribut, das per ::before als
   Beschriftung angezeigt wird. */
@media (max-width: 768px) {
    table.responsive-cards thead {
        display: none;
    }
    table.responsive-cards,
    table.responsive-cards tbody,
    table.responsive-cards tr,
    table.responsive-cards td {
        display: block;
        width: 100%;
    }
    table.responsive-cards {
        overflow-x: visible;
    }
    table.responsive-cards tr {
        margin-bottom: 12px;
        border: 1px solid #475569;
        border-radius: 6px;
        padding: 8px 10px;
        background: #1e293b;
    }
    table.responsive-cards td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        padding: 7px 2px;
        border: none;
        border-bottom: 1px solid #334155;
        text-align: right;
    }
    table.responsive-cards tr td:last-child {
        border-bottom: none;
    }
    table.responsive-cards td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #94a3b8;
        text-align: left;
        flex-shrink: 0;
        padding-right: 10px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    h1 { font-size: 22px !important; }
    h2 { font-size: 19px !important; }
    h3 { font-size: 16px !important; }
}
