/**
 * BOS-Trainer Responsive Styles
 * Mobile-Optimierung für alle Viewports
 * 
 * @since 2.2.11
 */

/* ============================================================
   TABLE RESPONSIVE: Card-Layout auf Mobile
   Jede .bos-table wird auf schmalen Screens zu gestackten Cards.
   Voraussetzung: <th> oder data-label auf <td>.
   ============================================================ */

/* Horizontaler Scroll als Basis-Fallback */
.bos-table {
    width: 100%;
}

@media (max-width: 768px) {

    /* ---- TABLE → CARD TRANSFORMATION ---- */
    .bos-table:not(.bos-table--no-stack) thead {
        display: none;
    }

    .bos-table:not(.bos-table--no-stack) tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 12px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .bos-table:not(.bos-table--no-stack) tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 6px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        font-size: 14px;
    }

    .bos-table:not(.bos-table--no-stack) tbody td:last-child {
        border-bottom: none;
    }

    /* Label aus data-label Attribut */
    .bos-table:not(.bos-table--no-stack) tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #1a3a5c;
        text-align: left;
        flex: 0 0 40%;
        padding-right: 10px;
        font-size: 13px;
    }

    /* Aktions-Links in Cards */
    .bos-table:not(.bos-table--no-stack) tbody td:last-child a {
        display: inline-block;
        margin: 2px 4px;
    }

    /* ---- SIDEBAR: Overlay auf Mobile (Bug #94, Schritt 4) ---- */
    /* Hauptregeln in bos-trainer.css, hier nur Ergänzungen */
    .bos-sidebar-nav__close {
        display: block !important;
    }

    /* Hamburger-Button (nur mobile sichtbar) */
    .bos-mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: #fff;
        font-size: 22px;
        cursor: pointer;
        margin-right: 8px;
        padding: 0;
        border-radius: 4px;
    }

    .bos-mobile-menu-btn:hover {
        background: rgba(255,255,255,0.1);
    }

    /* Content nimmt volle Breite */
    .bos-page-wrapper {
        flex-direction: column;
    }

    .bos-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
    }

    /* ---- FORMS: Single Column ---- */
    .bos-form-row,
    .bos-form-grid {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .bos-form-row > div,
    .bos-form-grid > div {
        width: 100% !important;
        flex: none !important;
    }

    /* Inline Forms (z.B. Filter) */
    form[style*="display: flex"] {
        flex-direction: column !important;
    }

    /* Buttons Stack */
    .bos-btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .bos-btn-group .button,
    .bos-btn-group .bos-btn {
        width: 100%;
        text-align: center;
    }

    /* ---- HEADER ---- */
    .bos-topbar {
        padding: 0 10px;
    }

    .bos-header {
        padding: 0 12px;
    }

    .bos-topbar__logo-text,
    .bos-header__logo-text {
        font-size: 16px;
    }

    .bos-header__nav {
        gap: 8px;
    }

    .bos-topbar__search,
    .bos-header__search {
        display: none;
    }

    /* Mobile Search Toggle */
    .bos-mobile-search {
        display: block !important;
        padding: 8px 10px;
        background: #1a3a5c;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .bos-mobile-search input {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid #ccc;
        border-radius: 20px;
        font-size: 14px;
    }

    /* ---- CARDS / BOXES ---- */
    .bos-box,
    .bos-card {
        margin: 8px 0;
        padding: 12px;
        border-radius: 8px;
    }

    /* Tabs scrollbar horizontal */
    .bos-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .bos-tabs a {
        font-size: 13px;
        padding: 8px 12px;
    }

    /* ---- DASHBOARD: Stats Grid ---- */
    .bos-stats-table td:first-child {
        font-weight: 600;
    }

    /* PLZ/Ort Felder nebeneinander halten */
    .bos-plz-ort-group {
        display: flex !important;
        gap: 8px;
    }

    .bos-plz-ort-group input:first-child {
        flex: 0 0 80px;
    }

    /* ---- FOOTER ---- */
    .bos-footer {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 15px 10px;
    }
}

/* ============================================================
   SMALL MOBILE (<480px) – Samsung S20, iPhone SE etc.
   ============================================================ */
@media (max-width: 480px) {
    .bos-topbar__logo-text,
    .bos-header__logo-text {
        font-size: 14px;
    }

    .bos-topbar__logo-img,
    .bos-header__logo img {
        height: 28px;
    }

    .bos-content {
        padding: 8px !important;
    }

    h2, .bos-page-title {
        font-size: 20px;
    }

    .bos-table:not(.bos-table--no-stack) tbody td {
        font-size: 13px;
    }

    /* Modal/Popup full width */
    .bos-modal-content,
    .bos-popup {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 10px auto;
    }

    /* Header kompakter */
    .bos-header {
        padding: 0 10px !important;
        height: 50px;
    }

    .bos-header__search {
        display: none;
    }

    .bos-header__nav {
        gap: 6px;
    }

    .bos-header__link {
        font-size: 12px;
        padding: 4px 8px;
    }

    .bos-header__username {
        display: none;
    }

    .bos-header__user-info {
        display: none;
    }

    /* Separator zwischen Login|Registrieren ausblenden auf engem Screen */
    .bos-header__separator {
        margin: 0 2px;
    }

    /* Card weniger Padding */
    .bos-card {
        padding: 12px !important;
    }

    /* Dashboard Kacheln: 2 Spalten statt auto-fit */
    .bos-quick-tile {
        padding: 14px !important;
    }
    .bos-quick-tile div[style*="font-size: 32px"] {
        font-size: 24px !important;
        margin-bottom: 4px !important;
    }
    .bos-quick-tile div[style*="font-size: 18px"] {
        font-size: 15px !important;
    }

    /* Dashboard Begrüßung */
    .bos-card > div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column;
        gap: 12px;
    }
    .bos-card > div[style*="display: flex"][style*="justify-content: space-between"] h2 {
        font-size: 18px !important;
    }

    /* Schnellstart-Buttons stacken */
    .bos-quick-actions {
        flex-direction: column;
    }
    .bos-quick-actions .bos-btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    /* Sparkline Cards kompakter */
    .bos-sparkline-card {
        padding: 12px;
    }
    .bos-sparkline-card__value {
        font-size: 1.3em;
    }

    /* Dashboard-Switcher kompakter */
    .bos-dashboard-switcher .bos-dashboard-switcher__btn {
        padding: 8px 10px !important;
        font-size: 13px !important;
    }

    /* Tabs enger */
    .bos-tabs a,
    .bos-tabs button {
        font-size: 12px;
        padding: 6px 8px;
    }

    /* Mini-Stats kompakter */
    .bos-mini-stat {
        min-width: 70px;
        padding: 8px;
    }
    .bos-mini-stat__value {
        font-size: 1.2em;
    }

    /* Tabellen Stats enger */
    .bos-table--stats td {
        padding: 5px 6px;
        font-size: 0.85em;
    }
}

/* ============================================================
   VERY SMALL MOBILE (<360px) – Compact devices
   ============================================================ */
@media (max-width: 360px) {
    .bos-header {
        padding: 0 6px !important;
    }

    .bos-header__logo-text {
        font-size: 13px;
    }

    .bos-header__logo img {
        height: 24px;
    }

    .bos-header__link {
        font-size: 11px;
        padding: 3px 6px;
    }

    .bos-content {
        padding: 6px !important;
    }

    .bos-card {
        padding: 10px !important;
        border-radius: 8px;
    }

    h2, .bos-page-title {
        font-size: 17px;
    }

    .bos-btn {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* ============================================================
   TABLET (769px - 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .bos-sidebar-nav {
        width: 200px;
        font-size: 13px;
    }

    .bos-sidebar-nav a {
        padding: 5px 8px;
    }

    .bos-content {
        padding: 15px;
    }
}

/* ============================================================
   HAMBURGER BUTTON: Hidden on desktop
   ============================================================ */
@media (min-width: 769px) {
    .bos-mobile-menu-btn {
        display: none !important;
    }

    .bos-mobile-search {
        display: none !important;
    }

    .bos-sidebar-overlay {
        display: none !important;
    }

    /* Header search is visible on desktop */
    .bos-header__search {
        display: block;
    }
}

/* ============================================================
   DARK MODE RESPONSIVE OVERRIDES
   ============================================================ */
@media (max-width: 768px) {
    .bos-dark .bos-table:not(.bos-table--no-stack) tbody tr {
        background: #1a1a2e;
        border-color: #333;
    }

    .bos-dark .bos-table:not(.bos-table--no-stack) tbody td {
        border-bottom-color: #2a2a3e;
    }

    .bos-dark .bos-table:not(.bos-table--no-stack) tbody td::before {
        color: #90caf9;
    }

    .bos-dark .bos-sidebar-nav {
        background: #0f0f23;
    }

    .bos-dark .bos-sidebar-overlay.active {
        background: rgba(0,0,0,0.6);
    }
}
