/* ========================================
   MOBILE OPTIMIZATION CSS
   ========================================

   WICHTIG: Diese Datei optimiert AUSSCHLIESSLICH die Mobile-Ansicht
   und beeinträchtigt die Desktop-Version NICHT.

   Alle Styles sind in @media queries für max-width: 768px eingeschlossen.
   ======================================== */

/* ========================================
   1. BASIS SCHRIFTGRÖSSEN & LESBARKEIT
   ======================================== */

@media (max-width: 768px) {
    /* Fix: Überschreibe die zu kleinen Schriftgrößen aus responsive-style.css */
    html,
    body {
        font-size: 16px !important; /* Lesbare Basis-Schriftgröße für Mobile */
        line-height: 1.5;
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
        overflow-x: hidden !important; /* KEIN horizontales Scrollen */
        max-width: 100vw !important;
    }

    /* Verhindere horizontales Scrollen - NUR auf Container-Elementen */
    .container,
    .container-fluid,
    .row {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: hidden !important;
    }

    /* Ausnahmen für Tabellen (die sollen scrollen) */
    .table-responsive,
    .table-responsive * {
        max-width: none !important;
    }

    /* Bessere Lesbarkeit für alle Textelemente */
    p, li, td, th, span, div {
        font-size: 14px !important;
        line-height: 1.6;
    }

    /* Überschriften skalierbar aber lesbar */
    h1 {
        font-size: 24px !important;
        line-height: 1.3;
        margin-bottom: 16px;
    }

    h2 {
        font-size: 20px !important;
        line-height: 1.3;
        margin-bottom: 14px;
    }

    h3 {
        font-size: 18px !important;
        line-height: 1.4;
        margin-bottom: 12px;
    }

    h4, h5, h6 {
        font-size: 16px !important;
        line-height: 1.4;
        margin-bottom: 10px;
    }

    /* Card Titles */
    .card-title {
        font-size: 16px !important;
        font-weight: 600;
    }

    .card-text {
        font-size: 14px !important;
    }
}

/* ========================================
   2. TABELLEN OPTIMIERUNG
   ======================================== */

@media (max-width: 768px) {
    /* Container für horizontales Scrollen */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Tabellen brauchen Mindestbreite für Lesbarkeit */
    .table {
        min-width: 800px !important; /* Verhindert Quetschung */
        margin-bottom: 0;
        font-size: 14px !important;
    }

    /* Tabellen Zellen - größere Touch Targets */
    .table td,
    .table th {
        padding: 12px 8px !important;
        font-size: 14px !important;
        vertical-align: middle;
        white-space: nowrap; /* Verhindert Textumbruch */
    }

    /* Depot Table spezifische Optimierungen */
    #depotTable td,
    #depotTable th {
        font-size: 14px !important;
        padding: 12px 10px !important;
    }

    /* Product Table */
    .product_table {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .product_table .table-responsive {
        margin-left: -15px;
        margin-right: -15px;
        border-radius: 0;
    }

    /* DataTables spezifische Anpassungen */
    .dataTables_wrapper {
        font-size: 14px !important;
    }

    .dataTables_length select,
    .dataTables_filter input {
        font-size: 14px !important;
        padding: 8px 12px !important;
        min-height: 44px; /* Touch-freundlich */
    }

    /* Table Controls */
    #tableSearch {
        font-size: 14px !important;
        padding: 12px 16px !important;
        min-height: 44px !important;
    }

    #entriesPerPage {
        font-size: 14px !important;
        padding: 10px 12px !important;
        min-height: 44px !important;
    }

    /* Column Toggle Panel */
    .column-toggle-card {
        font-size: 14px !important;
    }

    .column-toggle-card .form-check-label {
        font-size: 14px !important;
        padding-left: 8px;
    }

    /* Scroll Indikator für Tabellen */
    .table-responsive::after {
        content: "← Swipe für mehr →";
        display: block;
        text-align: center;
        font-size: 12px;
        color: #666;
        padding: 8px;
        background: #f8f9fa;
        border-top: 1px solid #dee2e6;
    }
}

/* ========================================
   3. BUTTONS & TOUCH TARGETS
   ======================================== */

@media (max-width: 768px) {
    /* ALLE Buttons mindestens 44px hoch (iOS Richtlinien) */
    .btn,
    button,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important;
        padding: 12px 20px !important;
        font-size: 16px !important;
        line-height: 1.2;
        margin-bottom: 8px;
        border-radius: 8px;
        touch-action: manipulation; /* Verhindert Zoom bei Doppeltipp */
    }

    /* Small Buttons */
    .btn-sm {
        min-height: 40px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }

    /* Button Groups - besserer Abstand */
    .d-flex.gap-1 {
        gap: 8px !important;
        flex-wrap: wrap;
    }

    /* Branded Buttons */
    .btn-branded {
        font-weight: 500;
        letter-spacing: 0.3px;
    }

    /* Icon Buttons */
    .btn-icon-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 12px !important;
        font-size: 18px !important;
    }

    /* Form Controls */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        min-height: 44px !important;
        padding: 12px 16px !important;
        font-size: 16px !important; /* Verhindert Auto-Zoom in iOS */
        border-radius: 8px;
    }

    /* Textarea spezielle Behandlung */
    textarea {
        min-height: 100px !important;
    }

    /* Search Input - Icon rechts statt links */
    .search-container {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        flex-direction: row-reverse !important; /* Icon nach rechts */
    }

    .search-container input {
        padding-left: 16px !important;
        padding-right: 44px !important; /* Platz für Icon rechts */
        flex: 1 !important;
    }

    .search-container .search-icon {
        position: absolute !important;
        right: 12px !important; /* Icon rechts positionieren */
        left: auto !important;
        pointer-events: none !important;
    }

    /* DataTables Filter Input */
    .dataTables_filter {
        text-align: right !important;
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
    }

    .dataTables_filter label {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        justify-content: flex-end !important;
    }

    /* Checkbox und Radio größer */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px !important;
        min-height: 20px !important;
        margin-right: 8px;
    }

    .form-check-input {
        width: 20px !important;
        height: 20px !important;
    }
}

/* ========================================
   4. NAVIGATION & DROPDOWN
   ======================================== */

@media (max-width: 768px) {
    /* Logo Section - Blauer Hintergrund muss sichtbar sein */
    .logo_section {
        background-color: #055195 !important;
        padding: 0.5rem 0 !important;
        position: relative;
        /* ENTFERNT overflow-x: hidden - könnte Menü blockieren */
    }

    .logo_section .container,
    .logo_section .container-fluid {
        padding-left: 12px !important;
        padding-right: 4px !important; /* Weniger Padding rechts für mehr Platz */
        max-width: 100% !important;
        /* ENTFERNT overflow-x: hidden - könnte Menü blockieren */
    }

    .logo_section .navbar {
        padding: 0.5rem 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
    }

    .logo_section .navbar-brand {
        margin-right: 0 !important;
        padding-right: 0 !important;
        flex-shrink: 0 !important;
    }

    /* Logo verkleinern auf Mobile */
    .logo_section .logo {
        width: 8rem !important; /* Noch kleiner für mehr Platz */
        flex-shrink: 0 !important;
    }

    .logo_section .logo img {
        max-width: 100%;
        height: auto;
    }

    /* Hamburger Menu - nach GANZ rechts verschoben mit Abstand zum Rand */
    .navbar-toggler {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px !important;
        font-size: 24px !important;
        border: 2px solid rgba(255, 255, 255, 0.5) !important;
        border-radius: 6px;
        margin-left: auto !important; /* Schiebt Button nach rechts */
        margin-right: 12px !important; /* Mehr Abstand zum rechten Rand */
        margin-top: -8px !important; /* Weiter nach oben */
        flex-shrink: 0 !important;
        position: relative;
        right: 0 !important;
    }

    .navbar-toggler-icon {
        width: 24px;
        height: 24px;
    }

    /* Navbar Collapse - Blauer Hintergrund */
    .navbar-collapse {
        background-color: #055195 !important;
        padding: 1rem 0;
        margin-top: 0.5rem;
        border-radius: 8px;
    }

    /* Navbar Items - weiße Schrift auf blau */
    .navbar-nav {
        width: 100%;
    }

    .navbar-nav .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-nav .nav-item:last-child {
        border-bottom: none;
    }

    .navbar-nav .nav-link {
        padding: 12px 16px !important;
        font-size: 16px !important;
        min-height: 48px;
        display: flex;
        align-items: center;
        color: #ffffff !important;
        background-color: transparent !important;
        transition: all 0.3s ease;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:active {
        background-color: rgba(255, 255, 255, 0.1) !important;
        padding-left: 24px !important;
    }

    /* Search in Navbar - VERSTECKEN auf Mobile (verursacht Overflow) */
    .navbar-nav #autocomplete,
    .navbar-nav form#autocomplete,
    .navbar .autocomplete,
    #autocomplete.navbar-form {
        display: none !important; /* Komplett verstecken um horizontales Scrollen zu verhindern */
    }

    /* Navbar muss sich an Bildschirmbreite anpassen */
    .navbar-nav,
    .navbar-collapse {
        width: 100% !important;
        max-width: 100% !important;
        /* ENTFERNT: overflow-x: hidden - blockiert Menü-Klicks */
    }

    /* Navbar Items dürfen nicht zu breit sein */
    .navbar-nav .nav-item,
    .navbar-nav .nav-link {
        max-width: 100% !important;
        word-wrap: break-word !important;
        /* Clickable machen */
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    /* Alternative: Wenn du es behalten willst, dann optimiert: */
    /*
    .navbar-nav #autocomplete {
        width: 100%;
        padding: 12px 16px;
        margin-bottom: 8px;
    }

    .navbar-nav #autocomplete .inner-form {
        width: 100%;
    }

    .navbar-nav #autocomplete .input-field {
        width: 100% !important;
        margin-right: 0 !important;
    }

    .navbar-nav #autocomplete input {
        width: 100% !important;
        min-height: 44px !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        background-color: rgba(255, 255, 255, 0.95) !important;
        color: #333 !important;
    }
    */

    /* Custom Dropdown Menu - BLAUER HINTERGRUND */
    .custom-dropdown {
        width: 100%;
    }

    .custom-dropdown > .nav-link {
        position: relative;
    }

    .custom-dropdown > .nav-link::after {
        content: '\f078';
        font-family: 'FontAwesome';
        margin-left: auto;
        font-size: 14px;
        transition: transform 0.3s ease;
    }

    .custom-dropdown:hover > .nav-link::after,
    .custom-dropdown-menu:hover ~ .nav-link::after {
        transform: rotate(180deg);
    }

    /* Dropdown Menu - Eingeklappt unter "Verwaltung" */
    .custom-dropdown-menu {
        position: static !important;
        display: none;
        width: 100% !important;
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        max-height: none !important;
    }

    /* Dropdown öffnen bei Hover/Touch */
    .custom-dropdown:hover .custom-dropdown-menu,
    .custom-dropdown:focus-within .custom-dropdown-menu,
    .custom-dropdown-menu:hover {
        display: block !important;
    }

    /* Dropdown Items - mit blauem Hintergrund */
    .custom-dropdown-menu a.custom-dropdown-item {
        padding: 14px 24px 14px 32px !important;
        font-size: 15px !important;
        min-height: 48px;
        display: flex;
        align-items: center;
        color: #ffffff !important;
        background-color: transparent !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-left: 3px solid transparent !important;
        transition: all 0.3s ease;
        text-decoration: none !important;
    }

    .custom-dropdown-menu a.custom-dropdown-item:last-child {
        border-bottom: none !important;
    }

    .custom-dropdown-menu a.custom-dropdown-item::before {
        display: none; /* Entfernt die weiße Linie von Desktop */
    }

    .custom-dropdown-menu a.custom-dropdown-item:hover,
    .custom-dropdown-menu a.custom-dropdown-item:active {
        background-color: rgba(255, 255, 255, 0.15) !important;
        border-left-color: #ffffff !important;
        padding-left: 36px !important;
        transform: none;
    }

    /* Alternative: Dropdown als ausgeklappte Liste (immer sichtbar) */
    /* Wenn du möchtest dass die Items immer sichtbar sind, aktiviere diese Zeile: */
    /* .custom-dropdown .custom-dropdown-menu { display: block !important; } */
}

/* ========================================
   5. MODALS
   ======================================== */

@media (max-width: 768px) {
    /* Modal kompakter auf Mobile - automatische Höhe */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
        width: calc(100% - 1rem) !important;
        display: flex !important;
        align-items: center !important;
        min-height: calc(100vh - 1rem) !important;
    }

    .modal-content {
        max-height: calc(100vh - 1rem) !important;
        border-radius: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        position: relative !important;
        z-index: 1056 !important; /* Über dem Backdrop */
    }

    /* Modal verhindert Body-Scroll */
    .modal {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .modal.show {
        overflow: hidden !important;
    }

    /* Modal Header - fixiert oben */
    .modal-header {
        padding: 10px 12px !important;
        flex-shrink: 0 !important;
        border-radius: 12px 12px 0 0 !important;
    }

    /* Modal Body - scrollbar wenn nötig */
    .modal-body {
        padding: 12px !important;
        overflow-y: auto !important;
        flex: 1 1 auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 200px) !important; /* Noch mehr Platz für Header/Footer */
        min-height: 0 !important; /* Wichtig für Flexbox Scrolling */
    }

    /* Modal Footer - fixiert unten */
    .modal-footer {
        padding: 10px 12px !important;
        flex-shrink: 0 !important;
        border-radius: 0 0 12px 12px !important;
    }

    /* Modal Titel - kleiner */
    .modal-title {
        font-size: 15px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
    }

    /* Close Button touchable */
    .modal-header .btn-close {
        min-width: 30px !important;
        min-height: 30px !important;
        padding: 6px !important;
        opacity: 1 !important;
    }

    /* Form Inputs in Modals - kompakter */
    .modal-body input[type="text"],
    .modal-body input[type="number"],
    .modal-body input[type="date"],
    .modal-body select,
    .modal-body textarea {
        padding: 8px 10px !important;
        font-size: 16px !important;
        min-height: 42px !important;
        margin-bottom: 8px !important;
        color: #1a202c !important;
        background: #ffffff !important;
        border: 2px solid #e3f2fd !important;
        border-radius: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Labels kompakter */
    .modal-body label {
        font-size: 13px !important;
        margin-bottom: 4px !important;
        display: block !important;
        color: #1e293b !important;
        font-weight: 600 !important;
    }

    /* Row spacing reduzieren */
    .modal-body .row {
        margin-bottom: 8px !important;
    }

    /* EDIT & SELL MODALS - Enable scrolling on mobile */
    #edit .modal-body,
    #sell .modal-body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 200px) !important;
    }

    /* EDIT & SELL MODALS - Stack vertically on mobile - ONLY .mt-4 rows */
    #edit .modal-body .row.mt-4,
    #sell .modal-body .row.mt-4 {
        flex-direction: column !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
    }

    #edit .modal-body .row.mt-4 .col-6,
    #edit .modal-body .row.mt-4 .col-7,
    #edit .modal-body .row.mt-4 .col-5,
    #sell .modal-body .row.mt-4 .col-6,
    #sell .modal-body .row.mt-4 .col-7,
    #sell .modal-body .row.mt-4 .col-5 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        display: block !important;
        text-align: left !important;
    }

    #edit .modal-body .row.mt-4 label,
    #sell .modal-body .row.mt-4 label {
        display: block !important;
        width: 100% !important;
        color: #1e293b !important;
        margin-bottom: 4px !important;
        text-align: left !important;
        justify-content: flex-start !important;
    }

    #edit .modal-body .row.mt-4 input,
    #edit .modal-body .row.mt-4 select,
    #edit .modal-body .row.mt-4 textarea,
    #sell .modal-body .row.mt-4 input,
    #sell .modal-body .row.mt-4 select,
    #sell .modal-body .row.mt-4 textarea {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 42px !important;
    }

    /* Ensure input wrapper elements don't hide inputs */
    #edit .modal-body .row.mt-4 .col-6 > *,
    #edit .modal-body .row.mt-4 .col-7 > *,
    #edit .modal-body .row.mt-4 .col-5 > *,
    #sell .modal-body .row.mt-4 .col-6 > *,
    #sell .modal-body .row.mt-4 .col-7 > *,
    #sell .modal-body .row.mt-4 .col-5 > * {
        display: block !important;
        width: 100% !important;
    }

    /* Buttons in Modals */
    .modal-footer .btn,
    .modal-body .btn {
        padding: 10px 14px !important;
        font-size: 14px !important;
        min-height: 42px !important;
        width: 100% !important;
        margin-top: 12px !important; /* Abstand damit Button erreichbar ist */
        margin-bottom: 8px !important;
    }

    /* Images in Modals */
    .modal-body img {
        max-width: 100% !important;
        height: auto !important;
        margin-bottom: 8px !important;
    }

    /* Alle Text-Elemente in Modals - DARK TEXT */
    .modal-body p,
    .modal-body span,
    .modal-body div,
    .modal-body strong,
    .modal-body b,
    .modal-body .form-text {
        color: #1a202c !important;
    }

    /* Placeholder Text auch dark */
    .modal-body input::placeholder,
    .modal-body textarea::placeholder {
        color: #64748b !important;
        opacity: 1 !important;
    }
}

/* ========================================
   6. CARDS & CONTAINERS
   ======================================== */

@media (max-width: 768px) {
    /* Cards volle Breite auf Mobile */
    .card {
        margin-bottom: 16px !important;
        border-radius: 12px !important;
    }

    .card-body {
        padding: 16px !important;
    }

    /* Container Padding reduzieren */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Rows */
    .row {
        margin-left: -12px !important;
        margin-right: -12px !important;
    }

    .row > * {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Product Section */
    .product_section {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Depot Cards - bessere Anordnung */
    .product_section .card {
        margin-bottom: 16px;
    }

    .product_section .card-body .row {
        margin-bottom: 8px;
    }
}

/* ========================================
   7. PRODUCT PAGE OPTIMIERUNGEN
   ======================================== */

@media (max-width: 768px) {
    /* Produktbild Slider */
    #productCarousel .carousel-inner {
        min-height: 250px !important;
    }

    #productCarousel .carousel-item {
        min-height: 250px !important;
    }

    #productCarousel .carousel-item img {
        max-height: 250px !important;
    }

    /* Product Details */
    .product_section .price_flex {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px;
    }

    .product_section .price_flex > div {
        width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* Product Name */
    .product_section .product_name {
        font-size: 16px !important;
        margin-bottom: 12px;
    }

    /* Prices besser lesbar */
    .product_section .product_price_discount {
        font-size: 18px !important;
        font-weight: 700;
    }

    /* Shop Cards */
    .singleShop {
        margin-bottom: 12px !important;
        padding: 16px !important;
    }

    /* Product Image */
    .product_section .product_img {
        max-height: 100px !important;
        margin-bottom: 12px;
    }

    /* Breadcrumb */
    .bread_crumb {
        font-size: 12px !important;
        line-height: 1.6;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
    }
}

/* ========================================
   8. DEALS PAGE
   ======================================== */

@media (max-width: 768px) {
    /* Deals Grid - Single Column */
    .deals-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Deal Cards */
    .deal-card {
        padding: 16px !important;
    }

    .deal-card img {
        max-height: 180px !important;
        margin-bottom: 12px;
    }

    /* Deal Info */
    .deal-info {
        font-size: 14px !important;
    }

    .deal-price {
        font-size: 20px !important;
        font-weight: 700;
    }

    .deal-discount {
        font-size: 16px !important;
    }
}

/* ========================================
   9. STATISTIK & CHARTS
   ======================================== */

@media (max-width: 768px) {
    /* Charts Container */
    .chart-container {
        padding: 12px !important;
        margin-bottom: 16px;
    }

    /* Chart Canvas */
    canvas {
        max-height: 250px !important;
    }

    /* Stats Cards */
    .statistik-page .card {
        margin-bottom: 16px;
    }

    .statistik-page .card-body {
        padding: 16px !important;
    }

    /* Stat Numbers */
    .stat-number {
        font-size: 24px !important;
        font-weight: 700;
    }

    .stat-label {
        font-size: 12px !important;
        color: #666;
    }
}

/* ========================================
   10. FORMS & LOGIN
   ======================================== */

@media (max-width: 768px) {
    /* Login/Register Forms */
    .s01 form .inner-form {
        padding: 24px 16px !important;
        flex-direction: column !important;
    }

    .s01 form .inner-form .input-field {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 12px !important;
        height: auto !important;
    }

    .s01 form .inner-form .input-field input {
        padding: 12px 16px !important;
        font-size: 16px !important;
        min-height: 44px !important;
    }

    .s01 form .inner-form .input-field.third-wrap .btn-search {
        min-height: 44px !important;
        font-size: 16px !important;
    }

    /* Form Groups */
    .form-group {
        margin-bottom: 16px !important;
    }

    .form-label {
        font-size: 14px !important;
        font-weight: 600;
        margin-bottom: 8px;
    }

    /* Autocomplete Dropdown */
    .autocomplete-modern {
        font-size: 14px !important;
    }

    .autocomplete-modern .autocomplete-item {
        padding: 12px 16px !important;
        min-height: 44px;
        font-size: 14px !important;
    }
}

/* ========================================
   11. FOOTER
   ======================================== */

@media (max-width: 768px) {
    .footer_section {
        padding: 24px 16px !important;
    }

    .footer_section .footer-links {
        flex-direction: column !important;
        gap: 16px;
    }

    .footer_section .footer-link {
        font-size: 14px !important;
        padding: 8px 0 !important;
    }

    .footer_section .social-icons {
        justify-content: center !important;
        margin-top: 16px;
    }

    .footer_section .social-icon {
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 20px !important;
    }
}

/* ========================================
   12. DEPOT PAGE SPEZIFISCH
   ======================================== */

@media (max-width: 768px) {
    /* Depot Stats Cards */
    .depot-page .card {
        margin-bottom: 16px !important;
    }

    /* Depot Value Cards - Stack Vertical */
    .depot-page .card-body .row .col-7,
    .depot-page .card-body .row .col-5,
    .depot-page .card-body .row .col-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        text-align: left !important;
        margin-bottom: 8px;
    }

    /* Depot Buttons - Stack Better */
    .depot-page .d-flex.flex-wrap {
        justify-content: center !important;
    }

    /* Table Controls besser anordnen */
    .depot-page .controls-wrapper {
        display: flex;
        gap: 8px;
        justify-content: space-between;
    }

    .depot-page .entries-select-wrapper {
        flex: 1;
    }
}

/* ========================================
   13. LAGER & KOSTEN PAGES
   ======================================== */

@media (max-width: 768px) {
    /* Warehouse Page */
    .lager-page .form-inline {
        flex-direction: column !important;
    }

    .lager-page .form-inline > * {
        width: 100% !important;
        margin-bottom: 12px !important;
    }

    /* Cost Management */
    .kosten-page .table-responsive {
        font-size: 14px !important;
    }

    .kosten-page .btn-group {
        flex-direction: column !important;
    }

    .kosten-page .btn-group .btn {
        width: 100% !important;
        margin-bottom: 8px;
    }
}

/* ========================================
   14. UTILITY CLASSES
   ======================================== */

@media (max-width: 768px) {
    /* Spacing Utilities für Mobile */
    .mb-mobile-3 {
        margin-bottom: 1rem !important;
    }

    .mt-mobile-3 {
        margin-top: 1rem !important;
    }

    .p-mobile-2 {
        padding: 0.5rem !important;
    }

    /* Text Alignment */
    .text-mobile-center {
        text-align: center !important;
    }

    /* Hide on Mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on Mobile */
    .show-mobile {
        display: block !important;
    }

    /* Full Width on Mobile */
    .w-mobile-100 {
        width: 100% !important;
    }

    /* No Wrap Prevention */
    .nowrap-mobile {
        white-space: normal !important;
        word-break: break-word;
    }
}

/* ========================================
   15. SCROLL BEHAVIOR & PERFORMANCE
   ======================================== */

@media (max-width: 768px) {
    /* Smooth Scrolling */
    html {
        scroll-behavior: smooth;
    }

    /* Momentum Scrolling für iOS */
    body,
    .table-responsive,
    .modal-body,
    .custom-dropdown-menu {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent Overscroll */
    body {
        overscroll-behavior-y: contain;
    }

    /* Performance: GPU Acceleration für Animationen */
    .btn,
    .card,
    .modal,
    .dropdown-menu {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }

    /* Tap Highlight entfernen */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Disable Text Selection bei Buttons */
    button,
    .btn,
    a.btn {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ========================================
   16. SAFARI/iOS SPEZIFISCHE FIXES
   ======================================== */

@media (max-width: 768px) {
    /* Fix für iOS Safari 100vh Problem */
    .modal-dialog,
    .full-height-mobile {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }

    /* Fix für iOS Input Zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important; /* Verhindert Auto-Zoom */
    }

    /* Fix für iOS Button Styling */
    input[type="submit"],
    input[type="button"],
    button {
        -webkit-appearance: none;
        appearance: none;
    }

    /* Safe Area für notched Devices */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ========================================
   17. ORIENTATION FIXES
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    /* Landscape optimierungen */
    .modal-dialog {
        max-width: 90vw !important;
        margin: auto !important;
    }

    #productCarousel .carousel-inner {
        min-height: 180px !important;
    }

    #productCarousel .carousel-item {
        min-height: 180px !important;
    }

    #productCarousel .carousel-item img {
        max-height: 180px !important;
    }
}

/* ========================================
   18. SMALL PHONES (< 400px)
   ======================================== */

@media (max-width: 400px) {
    /* Extra kleine Phones */
    .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .card-body {
        padding: 12px !important;
    }

    .btn {
        padding: 10px 16px !important;
        font-size: 14px !important;
    }

    h1 {
        font-size: 20px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    /* Tabellen noch schmaler */
    .table td,
    .table th {
        padding: 8px 6px !important;
        font-size: 13px !important;
    }
}

/* ========================================
   19. HOMEPAGE (/app) MOBILE OPTIMIERUNG
   ======================================== */

@media (max-width: 768px) {
    /* Hero Section - kompakt auf Mobile */
    .s01 {
        min-height: auto !important;
        padding: 80px 12px 40px 12px !important; /* Basis Padding */
        max-width: 100vw !important;
        overflow-x: hidden !important;
        width: 100% !important;
    }

    .s01 .container {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        padding-top: 60px !important; /* EXTRA Padding damit Header nicht überlappt */
        overflow-x: hidden !important;
    }

    /* Diagonale Background - weniger dominant auf Mobile */
    .s01::before {
        width: 100% !important;
        height: 200px !important;
        clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%) !important;
        opacity: 0.95;
    }

    .s01::after {
        width: 150px !important;
        height: 150px !important;
        opacity: 0.5;
    }

    /* Hauptüberschrift - kleiner auf Mobile */
    .s01 form legend,
    .s01 form h1 {
        font-size: 32px !important;
        line-height: 1.2 !important;
        margin-top: 0 !important; /* Kein extra margin oben */
        margin-bottom: 24px !important;
        text-align: center !important;
        max-width: 100% !important;
        padding: 0 !important;
        color: #ffffff !important; /* Weiß auf blauem Hintergrund */
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .s01 form h1::after {
        display: none; /* Unterstrich entfernen auf Mobile */
    }

    /* Search Form - volle Breite */
    .s01 form {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Search Box - volle Breite, VERTIKAL gestackt */
    .s01 form .inner-form {
        background: transparent !important;
        border-radius: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        flex-direction: column !important;
        display: flex !important;
        align-items: stretch !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .s01 form .inner-form .input-field {
        margin-right: 0 !important;
        margin-bottom: 0 !important;
        height: auto !important;
        width: 100% !important;
    }

    .s01 form .inner-form .input-field.first-wrap {
        flex: none !important;
        width: 100% !important;
    }

    .s01 form .inner-form .input-field.third-wrap {
        width: 100% !important;
        min-width: 100% !important;
    }

    .s01 form .inner-form .input-field input {
        padding: 14px 20px !important;
        font-size: 16px !important;
        min-height: 52px !important;
        border-radius: 50px !important;
        border: none !important;
        background: #ffffff !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
        width: 100% !important;
    }

    .s01 form .inner-form .input-field input::placeholder {
        font-size: 15px !important;
        color: #999 !important;
    }

    .s01 form .inner-form .input-field.third-wrap .btn-search {
        min-height: 52px !important;
        padding: 14px 24px !important;
        font-size: 16px !important;
        border-radius: 50px !important;
        font-weight: 600;
        white-space: nowrap;
        width: 100% !important;
        box-shadow: 0 4px 16px rgba(5, 81, 149, 0.3) !important;
    }

    /* Filter Button - BLAU mit weißer Schrift */
    .filter-toggle-btn {
        margin-top: 16px !important;
        width: 100% !important;
        max-width: 300px !important;
        min-height: 48px !important;
        padding: 12px 24px !important;
        font-size: 16px !important;
        border-radius: 50px !important;
        background: #055195 !important; /* BLAU statt weiß */
        color: #ffffff !important; /* WEIßE Schrift */
        border: 2px solid #055195 !important;
        box-shadow: 0 4px 12px rgba(5, 81, 149, 0.3) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        font-weight: 600 !important;
    }

    .filter-toggle-btn:hover {
        background: #043d6f !important;
        transform: translateY(-1px);
    }

    .filter-toggle-btn i {
        font-size: 16px;
        color: #ffffff !important;
    }

    /* Filter Panel */
    .filter-panel {
        margin-top: 16px !important;
        border-radius: 16px !important;
        padding: 16px !important;
    }

    .filter-panel-inner {
        padding: 0 !important;
    }

    .filter-header {
        margin-bottom: 16px !important;
    }

    .filter-header h3 {
        font-size: 18px !important;
        margin-bottom: 8px !important;
    }

    .reset-btn {
        min-height: 40px !important;
        padding: 8px 16px !important;
        font-size: 14px !important;
        border-radius: 20px !important;
    }

    /* Filter Inputs */
    .filter-panel input[type="text"],
    .filter-panel input[type="number"],
    .filter-panel select {
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        margin-bottom: 12px !important;
    }

    .filter-panel label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        font-weight: 600;
    }

    /* Filter Checkboxes */
    .filter-panel .form-check {
        margin-bottom: 12px !important;
    }

    .filter-panel .form-check-input {
        width: 20px !important;
        height: 20px !important;
        margin-right: 8px !important;
    }

    .filter-panel .form-check-label {
        font-size: 14px !important;
        padding-left: 8px;
    }

    /* Advanced Filter Section */
    .advanced-filter-section {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 16px !important;
        margin-top: 16px !important;
    }
}

/* ========================================
   20. HOMEPAGE - SEHR KLEINE PHONES
   ======================================== */

@media (max-width: 400px) {
    /* Noch kompaktere Homepage */
    .s01 {
        padding: 50px 12px 30px 12px !important;
    }

    .s01 form h1 {
        font-size: 28px !important;
    }

    .s01 form .inner-form {
        flex-direction: column !important;
        padding: 12px !important;
        gap: 12px !important;
    }

    .s01 form .inner-form .input-field {
        width: 100% !important;
    }

    .s01 form .inner-form .input-field.third-wrap {
        width: 100% !important;
        min-width: 100% !important;
    }

    .s01 form .inner-form .input-field.third-wrap .btn-search {
        width: 100% !important;
    }

    .filter-toggle-btn {
        max-width: 100% !important;
        font-size: 15px !important;
    }
}

/* ========================================
   21. PRODUCT CARDS & LEGO NEUHEITEN
   ======================================== */

@media (max-width: 768px) {
    /* LEGO Neuheiten Container */
    .product_section {
        width: 100% !important;
        max-width: 100% !important;
        padding: 16px 12px !important;
        overflow-x: hidden !important;
    }

    .product_section .container {
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* LEGO Neuheiten Überschrift - Fix für abgeschnittenen Text */
    .product_section h2,
    .product_section .page_heading,
    .product_section .product_heading,
    h2.page_heading,
    h2.product_heading {
        font-size: 18px !important;
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
        text-align: left !important;
        color: #000000 !important;
        word-wrap: break-word !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow: visible !important;
        white-space: normal !important;
        line-height: 1.3 !important;
        padding-right: 8px !important;
    }

    /* Row mit Überschrift + Button */
    .product_section .row.row-cols-3,
    .product_section .deal_box,
    #neuheiten-container {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 12px !important;
    }

    /* Erste Zeile: Überschrift + Aktualisieren Button */
    .product_section .row.row-cols-3 > .col-6:first-child,
    #neuheiten-container > .col-6:first-child {
        flex: 1 1 auto !important;
        max-width: calc(100% - 160px) !important; /* Platz für Button */
    }

    .product_section .row.row-cols-3 > .col-6:nth-child(2),
    #neuheiten-container > .col-6:nth-child(2) {
        flex: 0 0 auto !important;
        max-width: 150px !important;
    }

    /* Aktualisieren Button */
    .fancy-reload-btn {
        padding: 8px 12px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        white-space: nowrap !important;
    }

    /* Product Cards - EINSPALTIG auf Mobile */
    .product_section .row.row-cols-3 > .col-6.col-md-2,
    .product_section .row.row-cols-3 > .col-md-2,
    .product_section .search_box {
        flex: 0 0 100% !important; /* VOLLE Breite - eine Karte pro Zeile */
        max-width: 100% !important;
        width: 100% !important;
        margin-bottom: 16px !important;
    }

    /* Search Box (Product Cards) */
    .product_section .search_box {
        padding: 16px !important;
        border-radius: 12px !important;
        background: #ffffff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    .product_section .search_box img {
        max-width: 100% !important;
        height: auto !important;
        max-height: 200px !important;
        object-fit: contain !important;
        margin: 0 auto !important;
        display: block !important;
    }

    .product_section .search_box .wrap-box p {
        font-size: 14px !important;
        line-height: 1.4 !important;
        margin: 8px 0 !important;
        word-wrap: break-word !important;
    }

    .product_section .search_box .btn_blue {
        width: 100% !important;
        margin-top: 8px !important;
        padding: 12px !important;
        font-size: 14px !important;
    }

    /* APP Button Fix (unten rechts) */
    .app-button,
    .floating-app-button,
    [class*="app-btn"] {
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        z-index: 1000 !important;
        min-width: 60px !important;
        min-height: 60px !important;
        padding: 12px !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }
}

/* ========================================
   22. ACCOUNT VERWALTUNG PAGE
   ======================================== */

@media (max-width: 768px) {
    /* Account Page Container */
    .account-page {
        padding: 16px 12px !important;
    }

    /* Account Cards */
    .account-page .card {
        margin-bottom: 16px !important;
        border-radius: 12px !important;
        padding: 16px !important;
    }

    /* Account Informationen Überschrift - Kompakt aber lesbar */
    .account-page h2,
    .account-page .card h2,
    .account-page .card-title {
        font-size: 16px !important;
        line-height: 1.2 !important;
        margin-bottom: 10px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        padding: 8px 0 !important;
    }

    /* Account Icons neben Überschriften */
    .account-page h2 i,
    .account-page .card-title i {
        font-size: 16px !important;
        margin-right: 8px !important;
    }

    /* Account Form Inputs */
    .account-page input[type="text"],
    .account-page input[type="email"],
    .account-page input[type="number"] {
        width: 100% !important;
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 12px !important;
        margin-bottom: 12px !important;
    }

    /* Account Labels */
    .account-page label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        display: block !important;
        font-weight: 600 !important;
    }

    /* Speichern Button */
    .account-page .btn,
    .account-page button[type="submit"] {
        width: 100% !important;
        min-height: 44px !important;
        padding: 12px !important;
        font-size: 16px !important;
        margin-top: 8px !important;
    }

    /* Swipe für mehr Text */
    .account-page .swipe-hint {
        text-align: center !important;
        font-size: 12px !important;
        color: #666 !important;
        margin-top: 8px !important;
    }

    /* KRITISCH: Alle Sets löschen & Konto löschen Buttons */
    .account-page .modal-content,
    .account-page .modal-body {
        padding: 16px !important;
    }

    .account-page .modal-title {
        font-size: 18px !important;
        word-wrap: break-word !important;
        line-height: 1.3 !important;
    }

    .account-page .modal-body p,
    .account-page .modal-body div {
        font-size: 14px !important;
        line-height: 1.5 !important;
        word-wrap: break-word !important;
        margin-bottom: 12px !important;
    }

    /* Modal Footer Buttons - NICHT zu breit */
    .account-page .modal-footer {
        padding: 12px !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .account-page .modal-footer .btn,
    .account-page .modal-footer button {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 44px !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        margin: 0 !important;
        word-wrap: break-word !important;
        white-space: normal !important;
        text-align: center !important;
    }

    /* Löschen bestätigen Button - volle Breite */
    .account-page button[class*="delete"],
    .account-page button[class*="löschen"],
    .account-page .btn-danger {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ========================================
   23. APP BANNER / FLOAT PANEL - KOMPLETT NEU
   ======================================== */

@media (max-width: 768px) {
    /* App Float Panel - ULTRA KOMPAKT */
    .app-float-panel {
        width: 240px !important;
        max-width: 80vw !important;
        border-radius: 8px !important;
        padding: 0 !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    }

    .app-float-content {
        padding: 8px 6px !important;
    }

    .app-float-close {
        font-size: 16px !important;
        padding: 4px !important;
        top: 2px !important;
        right: 2px !important;
        line-height: 1 !important;
        width: 24px !important;
        height: 24px !important;
    }

    /* Header - ULTRA KOMPAKT */
    .app-float-header {
        display: flex !important;
        align-items: center !important;
        gap: 2px !important;
        margin-bottom: 3px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    .app-float-emoji {
        font-size: 12px !important;
        line-height: 1 !important;
    }

    /* Text - VERSTECKEN (zu lang) */
    .app-float-content p {
        display: none !important; /* Text komplett verstecken */
    }

    /* Buttons - KOMPAKT NEBENEINANDER */
    .app-float-buttons {
        display: flex !important;
        flex-direction: row !important;
        gap: 4px !important;
        margin-top: 4px !important;
    }

    .app-btn {
        flex: 1 !important;
        padding: 6px 3px !important;
        font-size: 9px !important;
        min-height: 26px !important;
        height: 26px !important;
        max-height: 26px !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        border-radius: 4px !important;
        font-weight: 600 !important;
        line-height: 1 !important;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
    }

    .app-btn-ios {
        background: #007AFF !important;
        color: white !important;
        border: none !important;
    }

    .app-btn-android {
        background: #3DDC84 !important;
        color: white !important;
        border: none !important;
    }

    /* Trigger Button */
    .app-float-trigger {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* ========================================
   DETAIL VIEW - TABLE CONTROLS (MOBILE)
   ======================================== */

@media (max-width: 768px) {
    /* Controls Wrapper - Stack vertically */
    .controls-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Export Button - Full width */
    .btn-csv-export {
        width: 100% !important;
        margin: 0 !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
    }

    /* Column Toggle Button - Full width */
    .btn-icon-toggle {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
    }

    /* Entries Dropdown Wrapper - Full width */
    .entries-select-wrapper {
        width: 100% !important;
    }

    .entries-select-wrapper select {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
    }

    /* Search Container - Better spacing */
    .search-container {
        margin-bottom: 12px !important;
    }

    .search-container input {
        font-size: 16px !important;
        padding: 12px 16px 12px 40px !important;
    }
}

/* ========================================
   FIN - Mobile Optimization Complete
   ======================================== */
