/* ==========================================================================
   CannaKompass - Mobile Web-App Stylesheet (mobile.css)
   STRENG ISOLIERT FÜR MOBILGERÄTE (DESKTOP BLEIBT 100% UNANGETASTET)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Globale Defaults für Mobil-Elemente auf Desktop (strikt ausgeblendet)
   -------------------------------------------------------------------------- */
.mobile-bottom-dock,
.mobile-drawer-overlay,
.mobile-drawer,
.mobile-channel-chips {
    display: none !important;
}

/* --------------------------------------------------------------------------
   2. TABLETS & MOBILGERÄTE (<= 991px)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    
    /* Body & App Container */
    body {
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
    }
    
    .app-container {
        overflow-x: hidden;
        min-width: 0;
    }

    /* --- 2.1 3-SPALTEN-LAYOUT: CONTENT-FIRST REORDERING --- */
    .grid-3-columns {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        padding: 0 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 24px auto !important;
    }

    /* 1. Hauptinhalt steht IMMER ganz oben */
    .grid-3-columns > .page-container {
        order: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 2. Linke Sidebar unter dem Hauptinhalt */
    .grid-3-columns > .sidebar-left {
        order: 2 !important;
        position: static !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px !important;
        padding: 16px !important;
        margin-top: 8px !important;
    }

    /* 3. Rechte Sidebar (Widgets) ganz unten */
    .grid-3-columns > .sidebar-right {
        order: 3 !important;
        position: static !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px !important;
        padding: 16px !important;
    }

    /* --- 2.2 PAGE HEADER & HORIZONTALE TAB-LEISTEN --- */
    .page-header-section {
        padding: 20px 14px 22px 14px !important;
        margin: 10px auto 18px auto !important;
        border-radius: 18px !important;
    }

    .page-header-title {
        font-size: clamp(1.45rem, 5vw, 1.95rem) !important;
        letter-spacing: -0.015em !important;
        gap: 8px !important;
    }

    .page-header-desc {
        font-size: 0.88rem !important;
        line-height: 1.45 !important;
        margin-bottom: 12px !important;
    }

    .page-header-tabs-wrapper {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important; /* Firefox */
        margin: 0 -14px !important;
        padding: 0 14px !important;
    }

    .page-header-tabs-wrapper::-webkit-scrollbar {
        display: none !important; /* Chrome / Safari */
    }

    .page-header-tabs-wrapper .tab-navigation {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 8px !important;
        width: max-content !important;
        min-width: 100% !important;
        padding: 4px 0 6px 0 !important;
    }

    .tab-btn {
        padding: 8px 16px !important;
        font-size: 0.88rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        border-radius: 24px !important;
    }

    /* Flanken-Header auf Tablets ausblenden */
    .page-header-flanks {
        display: none !important;
    }

    /* --- 2.3 HIGHLIGHT SHOWREEL: GENAU 1 BANNER PRO SLIDE VOLLFLÄCHIG OHNE SEITLICHE ABSTÄNDE/BALKEN --- */
    .page-header-section.home-highlights-header {
        padding: 16px 12px 18px 12px !important;
    }

    .home-highlights-header .hero-slider-container {
        position: relative !important;
        width: 100% !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .home-highlights-header .hero-slider-track-wrapper {
        width: 100% !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .home-highlights-header .hero-slider-track-wrapper::-webkit-scrollbar {
        display: none !important;
    }

    .home-highlights-header .hero-slider-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        grid-template-columns: none !important;
        gap: 0 !important;
        width: 100% !important;
    }

    .home-highlights-header .hero-slider-item {
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        scroll-snap-align: center !important;
        scroll-snap-stop: always !important;
        box-sizing: border-box !important;
        aspect-ratio: 6 / 1 !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        background: transparent !important;
        display: block !important;
        margin: 0 !important;
    }

    .home-highlights-header .hero-slider-item img {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 6 / 1 !important;
        object-fit: cover !important;
        border-radius: 11px !important;
        display: block !important;
    }

    /* Schwebende Glas-Pfeile auf dem Banner (verhindern seitliche Leeräume & schwarze Balken) */
    .home-highlights-header .slider-arrow {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 10 !important;
        width: 32px !important;
        height: 32px !important;
        background: rgba(18, 18, 18, 0.72) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        border: 1px solid rgba(255, 255, 255, 0.22) !important;
        border-radius: 50% !important;
        color: #fff !important;
        font-size: 1.15rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6) !important;
        cursor: pointer !important;
        padding: 0 !important;
        transition: transform 0.2s ease, background 0.2s ease !important;
    }

    .home-highlights-header .slider-arrow:active {
        transform: translateY(-50%) scale(0.92) !important;
        background: rgba(10, 207, 131, 0.3) !important;
    }

    .home-highlights-header .slider-arrow-prev {
        left: 8px !important;
    }

    .home-highlights-header .slider-arrow-next {
        right: 8px !important;
    }

    /* --- 2.4 FEED- & NEWS-ARTIKEL: GENAU 1 ARTIKEL PRO ZEILE --- */
    .home-news-grid,
    .home-grid-5.home-news-grid,
    .articles-feed-list,
    .community-feed {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        width: 100% !important;
    }

    .news-home-card {
        width: 100% !important;
        height: auto !important;
        min-height: 230px !important;
        aspect-ratio: 16 / 9 !important;
        border-radius: 16px !important;
        margin: 0 !important;
    }

    /* In der mobilen Ansicht nur genau 3 Feed-Artikel ausgeben (statt 5 wie auf Desktop) */
    .home-news-grid .news-home-card:nth-child(n+4) {
        display: none !important;
    }

    /* --- 2.5 FEED & COMMUNITY POST-KARTEN --- */
    .community-feed-item,
    .news-card-featured,
    .news-card-regular,
    .user-profile-header-card,
    .user-profile-tab-card {
        border-radius: 16px !important;
    }

    .home-section-container {
        padding: 0 12px !important;
    }
}

/* --------------------------------------------------------------------------
   3. SMARTPHONES & KLEINE DISPLAYS (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

    /* Platz für die untere App-Bottom-Dock freihalten */
    body {
        padding-bottom: 74px !important;
    }

    /* --- 3.1 TOP-NAVBAR KOMPAKTIERUNG --- */
    .main-navbar {
        padding: 8px 0 !important;
    }

    .main-navbar > div {
        padding: 0 14px !important;
        gap: 10px !important;
    }

    .navbar-brand {
        font-size: 1.15rem !important;
        gap: 6px !important;
    }

    .navbar-brand i {
        font-size: 1.35rem !important;
    }

    /* Desktop-Icons auf das Wesentliche reduzieren */
    .navbar-icons li:has(.bi-search),
    .navbar-icons li:has(.bi-chat-dots-fill),
    .navbar-icons li:has(#settingsNavDropdown) {
        display: none !important;
    }

    .navbar-icons {
        gap: 6px !important;
    }

    .nav-icon-link {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        font-size: 1.05rem !important;
    }

    .nav-login-btn {
        height: 34px !important;
        padding: 0 14px !important;
        font-size: 0.84rem !important;
        border-radius: 20px !important;
    }

    .navbar-toggler {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        font-size: 1.25rem !important;
    }

    /* --- 3.2 MOBILE OFF-CANVAS DRAWER --- */
    .mobile-drawer-overlay {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
    }

    .mobile-drawer-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .mobile-drawer {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 84%;
        max-width: 330px;
        background: rgba(22, 22, 22, 0.98);
        border-left: 1px solid rgba(10, 207, 131, 0.3);
        box-shadow: -10px 0 35px rgba(0, 0, 0, 0.7);
        z-index: 2001;
        transform: translateX(100%);
        transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px 18px 80px 18px;
    }

    html:not(.dark-mode) .mobile-drawer {
        background: rgba(255, 255, 255, 0.98);
        border-left: 1px solid rgba(10, 207, 131, 0.25);
    }

    .mobile-drawer-overlay.show .mobile-drawer {
        transform: translateX(0);
    }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 16px;
        margin-bottom: 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-drawer-title {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--primary-color);
    }

    .mobile-drawer-close {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid var(--border-color);
        color: var(--text-main);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-drawer-nav {
        list-style: none;
        padding: 0;
        margin: 0 0 20px 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-drawer-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 12px;
        color: var(--text-main);
        text-decoration: none;
        font-size: 0.98rem;
        font-weight: 600;
        transition: all 0.2s;
    }

    .mobile-drawer-link i {
        font-size: 1.2rem;
        color: var(--primary-color);
        width: 24px;
        text-align: center;
    }

    .mobile-drawer-link:hover,
    .mobile-drawer-link.active {
        background: rgba(10, 207, 131, 0.12);
        color: var(--primary-color);
    }

    .mobile-drawer-section-title {
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-muted);
        letter-spacing: 0.05em;
        margin: 16px 0 8px 12px;
    }

    .mobile-drawer-actions {
        padding: 14px;
        background: var(--bg-tab-btn);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* --- 3.3 APP-STYLE BOTTOM NAVIGATION DOCK --- */
    .mobile-bottom-dock {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(18, 18, 18, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(10, 207, 131, 0.28);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45);
        z-index: 1050;
        align-items: center;
        justify-content: space-around;
        padding: 0 4px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: content-box;
    }

    html:not(.dark-mode) .mobile-bottom-dock {
        background: rgba(255, 255, 255, 0.95);
        border-top: 1px solid rgba(10, 207, 131, 0.25);
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    }

    .mobile-dock-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        height: 100%;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.70rem;
        font-weight: 600;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 4px 2px;
        position: relative;
        touch-action: manipulation;
    }

    .mobile-dock-item i {
        font-size: 1.25rem;
        line-height: 1;
        color: inherit;
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
    }

    .mobile-dock-item:hover,
    .mobile-dock-item:active {
        color: var(--primary-color);
    }

    .mobile-dock-item.active {
        color: var(--primary-color) !important;
        font-weight: 700;
    }

    .mobile-dock-item.active i {
        transform: translateY(-2px);
        color: var(--primary-color) !important;
        filter: drop-shadow(0 0 8px rgba(10, 207, 131, 0.5));
    }

    .mobile-dock-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--primary-color);
        border-radius: 0 0 4px 4px;
        box-shadow: 0 0 8px rgba(10, 207, 131, 0.7);
    }

    /* --- 3.4 HORIZONTALE CHANNEL-CHIPS (COMMUNITY) --- */
    .mobile-channel-chips {
        display: flex !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
        padding: 6px 2px 14px 2px;
        margin: -4px 0 10px 0;
    }

    .mobile-channel-chips::-webkit-scrollbar {
        display: none;
    }

    .mobile-channel-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: var(--bg-tab-btn);
        border: 1px solid var(--border-color);
        border-radius: 20px;
        padding: 7px 14px;
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-main);
        text-decoration: none;
        white-space: nowrap;
        flex-shrink: 0;
        transition: all 0.2s;
    }

    .mobile-channel-chip i {
        color: var(--primary-color);
        font-size: 0.9rem;
    }

    .mobile-channel-chip.active {
        background: rgba(10, 207, 131, 0.16);
        border-color: var(--primary-color);
        color: var(--primary-color);
        box-shadow: 0 0 10px rgba(10, 207, 131, 0.25);
    }

    /* --- 3.5 KOMPAKTE FEED & COMMUNITY KARTEN --- */
    .community-feed-item,
    .community-post-card {
        padding: 14px 14px 12px 14px !important;
        margin-bottom: 14px !important;
    }

    .post-header {
        gap: 10px !important;
    }

    .post-avatar {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
    }

    .post-author-name {
        font-size: 0.95rem !important;
    }

    .post-meta-sub {
        font-size: 0.78rem !important;
    }

    .post-text-content,
    .post-body {
        font-size: 0.92rem !important;
        line-height: 1.5 !important;
        margin: 10px 0 !important;
    }

    .post-image-container img,
    .post-media img {
        border-radius: 10px !important;
        max-height: 380px !important;
        object-fit: cover !important;
        width: 100% !important;
    }

    /* Post Actions Touch-Bar */
    .post-actions,
    .post-footer {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 6px !important;
        padding-top: 10px !important;
        margin-top: 10px !important;
        border-top: 1px solid var(--border-color) !important;
    }

    .btn-action,
    .post-interaction-btn {
        flex: 1 1 auto !important;
        justify-content: center !important;
        padding: 8px 6px !important;
        font-size: 0.82rem !important;
        border-radius: 10px !important;
        min-height: 38px !important;
    }

    .btn-action i,
    .post-interaction-btn i {
        font-size: 1.05rem !important;
    }

    /* --- 3.6 SORTEN-LISTE, STRAIN-DETAILS & GROW-MANAGER (MOBILE) --- */
    .strain-list-item:not(.home-strains-compact .strain-list-item) .accordion-button-custom-content {
        padding-right: 42px !important;
    }

    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-title-group,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-release-wrapper,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-origin-flags-wrapper,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-seed-type-col,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-type-col,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-ratio-col,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-cannabinoids-col,
    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-terpenes-col {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
        border-right: none !important;
        padding-right: 0 !important;
    }

    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-title-group {
        width: 100% !important;
        margin-bottom: 4px !important;
    }

    .strain-list-item:not(.home-strains-compact .strain-list-item) .strain-terpenes-col {
        flex-wrap: wrap !important;
    }

    /* Strain Details Responsive */
    .adv-donut-container {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 16px !important;
    }

    .strain-info-container > div > div {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Grow Manager Responsive */
    .grow-stage-timeline {
        overflow-x: auto !important;
        gap: 12px !important;
        padding-bottom: 6px !important;
        -webkit-overflow-scrolling: touch;
    }

    .wizard-options-grid,
    .grow-kpi-grid,
    .grow-modules-grid {
        grid-template-columns: 1fr !important;
    }

    #wizardConfigContainer,
    #wizardResultContainer,
    #wizardConfigSummaryContainer {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100% !important;
    }

    #wizardConfigContainer table,
    #wizardResultContainer table,
    #wizardConfigSummaryContainer table {
        min-width: 580px;
    }

    .grow-setup-actions {
        flex-wrap: wrap !important;
        justify-content: stretch !important;
    }

    .grow-setup-actions .btn {
        flex: 1 1 auto !important;
    }

    /* Formulare & Eingaben (Verhindert Auto-Zoom auf iPhones) */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* --------------------------------------------------------------------------
   4. SEHR SCHMALE SMARTPHONES & PRODUKT-GRIDS (<= 600px)
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {

    /* --- 4.1 2-SPALTEN-RASTER FÜR SHOP & PRODUKTE --- */
    .home-products-grid,
    .home-grid-5.home-products-grid,
    .home-grid-5:not(.home-news-grid), 
    .home-grid-4, 
    .home-grid-3,
    .shop-products-grid,
    .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    /* Feed & News-Artikel stets strikt 1 Artikel pro Zeile */
    .home-news-grid,
    .home-grid-5.home-news-grid,
    .articles-feed-list {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }

    .home-product-card,
    .product-card {
        padding: 10px !important;
        border-radius: 14px !important;
    }

    .home-product-thumb {
        height: 120px !important;
    }

    .home-product-card h3,
    .product-card h3 {
        font-size: 0.82rem !important;
        line-height: 1.25 !important;
        margin-bottom: 4px !important;
    }

    .home-product-price {
        font-size: 0.88rem !important;
    }

    /* Filter & Suchfelder vollflächig */
    .subchannel-search-box input {
        width: 100% !important;
    }

    /* Modale Fenster als Bottom-Sheet */
    .modal-content {
        width: 95% !important;
        max-height: 88vh !important;
        border-radius: 20px 20px 12px 12px !important;
        padding: 20px 16px !important;
    }
}
