/**
 * Zigcy Lite - Mobile Web App Styles
 * Makes the website look and feel like a native mobile app
 * Uses !important to override theme defaults where needed
 */

/* ============================================
   BASE MOBILE RESETS & WEB APP BEHAVIOR
   ============================================ */

@media screen and (max-width: 768px) {

    /* Prevent text resize on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    body {
        overflow-x: hidden !important;
        -webkit-tap-highlight-color: transparent;
        width: 100% !important;
        min-height: 100vh;
        padding-bottom: 70px !important;
        overscroll-behavior-y: contain;
    }

    /* ============================================
       HEADER - COMPACT APP-LIKE HEADER
       ============================================ */

    .site-header,
    header.site-header,
    .zigcy-header-wrapper,
    .header-wrapper,
    .zigcy-lite-starter-developer .site-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 9999 !important;
        background: #fff !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
        padding: 10px 15px !important;
        max-height: 60px !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    /* ============================================
       LOGO - CONSTRAINED SIZE
       ============================================ */

    .site-branding img,
    .custom-logo,
    .site-header img,
    .zigcy-header-wrapper img,
    header img,
    .custom-logo-link img,
    img.custom-logo {
        max-height: 40px !important;
        width: auto !important;
        max-width: 150px !important;
        height: auto !important;
        object-fit: contain !important;
    }

    .site-branding,
    .custom-logo-link,
    .site-branding a {
        display: flex !important;
        align-items: center !important;
        max-height: 50px !important;
        overflow: hidden !important;
    }

    /* Hide site title/description if logo exists */
    .site-title {
        font-size: 18px !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .site-description {
        display: none !important;
    }

    /* ============================================
       HERO/BANNER SECTION - COMPACT
       ============================================ */

    .zigcy-banner-section,
    .banner-wrapper,
    .hero-section,
    .zigcy-slider-section,
    .home-slider,
    section.zigcy-banner-section {
        max-height: 200px !important;
        overflow: hidden !important;
    }

    .zigcy-banner-section img,
    .banner-wrapper img,
    .hero-section img,
    .zigcy-slider-section img {
        max-height: 200px !important;
        width: 100% !important;
        object-fit: cover !important;
    }

    /* ============================================
       LAYOUT - FULL WIDTH MOBILE
       ============================================ */

    .container,
    .starter-developer .container,
    body .container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box !important;
    }

    .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
    }

    .row > [class*="col-"] {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Full-width columns on mobile */
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9, .col-md-12,
    .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-8, .col-lg-9, .col-lg-12 {
        width: 100% !important;
        float: none !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* ============================================
       HEADER - DUPLICATE REMOVED (handled above)
       ============================================ */

    /* Hide desktop nav, show mobile toggle */
    .main-navigation ul,
    .primary-menu,
    .zigcy-main-menu > ul {
        display: none !important;
    }

    .menu-toggle,
    .zigcy-menu-toggle,
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        background: none !important;
        border: none !important;
        font-size: 24px !important;
        cursor: pointer;
        padding: 0 !important;
    }

    /* Mobile menu open state */
    .main-navigation.toggled ul,
    .primary-menu.toggled,
    .mobile-nav-active .primary-menu {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        background: #fff !important;
        z-index: 99999 !important;
        overflow-y: auto !important;
        padding: 60px 20px 20px !important;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15) !important;
        animation: slideInLeft 0.3s ease;
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-100%);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    .main-navigation.toggled li,
    .mobile-nav-active .primary-menu li {
        display: block !important;
        border-bottom: 1px solid #f0f0f0;
    }

    .main-navigation.toggled li a,
    .mobile-nav-active .primary-menu li a {
        display: block !important;
        padding: 14px 15px !important;
        font-size: 16px !important;
        color: #333 !important;
        text-decoration: none !important;
    }

    /* Sub-menus in mobile nav */
    .main-navigation.toggled .sub-menu,
    .mobile-nav-active .sub-menu {
        position: static !important;
        box-shadow: none !important;
        padding-left: 20px !important;
        background: #fafafa !important;
    }

    /* ============================================
       CONTENT AREA - CLEAN MOBILE LAYOUT
       ============================================ */

    .site-content {
        padding: 15px 0 !important;
    }

    /* Hide sidebar on mobile for app-like feel */
    .sidebar,
    .widget-area,
    #secondary,
    .zigcy-sidebar {
        display: none !important;
    }

    /* Make content full width when sidebar hidden */
    .content-area,
    #primary,
    .zigcy-content-area {
        width: 100% !important;
        float: none !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* ============================================
       TYPOGRAPHY - MOBILE OPTIMIZED
       ============================================ */

    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }
    h5 { font-size: 15px; }
    h6 { font-size: 14px; }

    p, li, td, th {
        font-size: 15px;
        line-height: 1.6;
    }

    /* ============================================
       IMAGES & MEDIA - RESPONSIVE
       ============================================ */

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

    .wp-block-image,
    .wp-block-cover {
        margin-left: 0;
        margin-right: 0;
    }

    iframe,
    embed,
    video {
        max-width: 100%;
        width: 100%;
    }

    /* ============================================
       BUTTONS - APP-LIKE TOUCH BUTTONS
       ============================================ */

    .btn,
    .button,
    input[type="submit"],
    input[type="button"],
    .woocommerce a.button,
    .woocommerce button.button,
    .woocommerce input.button,
    .wp-block-button__link {
        padding: 12px 24px;
        font-size: 15px;
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }

    .btn:active,
    .button:active,
    input[type="submit"]:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* ============================================
       FORMS - MOBILE OPTIMIZED INPUT
       ============================================ */

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        width: 100%;
        padding: 12px 15px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        border: 1px solid #ddd;
        border-radius: 8px;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
    }

    input:focus,
    textarea:focus,
    select:focus {
        border-color: #0073aa;
        outline: none;
        box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
    }

    /* ============================================
       HOMEPAGE SECTIONS - APP CARDS
       ============================================ */

    .zigcy-home-section,
    .home-section,
    .section-wrapper {
        padding: 20px 0;
        margin: 0;
    }

    /* Card-style sections */
    .zigcy-home-section .section-inner,
    .home-product-section,
    .featured-section {
        background: #fff;
        border-radius: 12px;
        padding: 20px 15px;
        margin-bottom: 15px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    }

    .section-title,
    .zigcy-section-title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 2px solid #f0f0f0;
    }

    /* ============================================
       WOOCOMMERCE - PRODUCT GRID MOBILE
       ============================================ */

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0;
        margin: 0;
    }

    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product {
        width: 100% !important;
        margin: 0 !important;
        padding: 0;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        transition: transform 0.2s ease;
    }

    .woocommerce ul.products li.product:active {
        transform: scale(0.98);
    }

    .woocommerce ul.products li.product img {
        width: 100%;
        height: auto;
        border-radius: 10px 10px 0 0;
    }

    .woocommerce ul.products li.product .woocommerce-loop-product__title {
        font-size: 13px;
        padding: 8px 10px 4px;
        line-height: 1.3;
    }

    .woocommerce ul.products li.product .price {
        font-size: 14px;
        font-weight: 600;
        padding: 0 10px 8px;
    }

    .woocommerce ul.products li.product .button,
    .woocommerce ul.products li.product a.add_to_cart_button {
        width: calc(100% - 20px);
        margin: 0 10px 10px;
        padding: 10px;
        font-size: 13px;
        border-radius: 6px;
        min-height: 40px;
    }

    /* Single product page */
    .woocommerce div.product {
        padding: 15px;
    }

    .woocommerce div.product div.images {
        width: 100% !important;
        float: none !important;
        margin-bottom: 20px;
    }

    .woocommerce div.product div.summary {
        width: 100% !important;
        float: none !important;
    }

    .woocommerce div.product .product_title {
        font-size: 20px;
    }

    .woocommerce div.product p.price {
        font-size: 22px;
        font-weight: 700;
    }

    .woocommerce div.product .quantity {
        margin-right: 10px;
    }

    .woocommerce div.product .single_add_to_cart_button {
        flex: 1;
        width: auto;
    }

    .woocommerce div.product form.cart {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* Cart page */
    .woocommerce table.shop_table {
        display: block;
        overflow-x: auto;
        font-size: 14px;
    }

    .woocommerce .cart-collaterals,
    .woocommerce-page .cart-collaterals {
        width: 100%;
        float: none;
    }

    /* ============================================
       FOOTER - COMPACT MOBILE FOOTER
       ============================================ */

    .site-footer,
    .zigcy-footer-wrapper {
        padding: 20px 15px;
        text-align: center;
    }

    .footer-widget-area .widget {
        margin-bottom: 25px;
    }

    .site-footer .widget-title {
        font-size: 16px;
    }

    /* ============================================
       BOTTOM NAVIGATION BAR (APP-LIKE)
       ============================================ */

    .zigcy-mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
        z-index: 99998;
        border-top: 1px solid #f0f0f0;
    }

    .zigcy-mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #666;
        font-size: 10px;
        padding: 4px 12px;
        min-height: 44px;
        transition: color 0.2s;
    }

    .zigcy-mobile-bottom-nav a.active,
    .zigcy-mobile-bottom-nav a:hover {
        color: #0073aa;
    }

    .zigcy-mobile-bottom-nav a i,
    .zigcy-mobile-bottom-nav a .dashicons,
    .zigcy-mobile-bottom-nav a svg {
        font-size: 20px;
        width: 20px;
        height: 20px;
        margin-bottom: 3px;
    }

    /* Add padding to body for bottom nav */
    body {
        padding-bottom: 70px;
    }

    /* ============================================
       SLIDERS/CAROUSELS - MOBILE OPTIMIZED
       ============================================ */

    .owl-carousel .owl-item,
    .slick-slide {
        padding: 0 5px;
    }

    .owl-carousel .owl-nav,
    .slick-prev, .slick-next {
        display: none !important;
    }

    .owl-carousel .owl-dots,
    .slick-dots {
        margin-top: 10px;
    }

    .owl-carousel .owl-dots .owl-dot span,
    .slick-dots li button {
        width: 8px;
        height: 8px;
    }

    /* Banner/Slider */
    .zigcy-banner-section,
    .banner-wrapper,
    .hero-section {
        border-radius: 0;
        margin: 0 -15px;
    }

    .zigcy-banner-section .banner-content,
    .banner-wrapper .banner-text {
        padding: 30px 20px;
    }

    .zigcy-banner-section h2,
    .banner-wrapper h2 {
        font-size: 22px;
        line-height: 1.3;
    }

    /* ============================================
       UTILITIES & ANIMATIONS
       ============================================ */

    /* Smooth scroll for anchor links */
    html {
        scroll-behavior: smooth;
    }

    /* Pull-to-refresh feel */
    body {
        overscroll-behavior-y: contain;
    }

    /* Hide elements not needed on mobile */
    .desktop-only,
    .hide-mobile {
        display: none !important;
    }

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

    /* Loading state for async content */
    .loading {
        opacity: 0.6;
        pointer-events: none;
    }

    /* Smooth page transitions */
    .site-content {
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* ============================================
   EXTRA SMALL DEVICES (320px - 480px)
   ============================================ */

@media screen and (max-width: 480px) {

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .woocommerce ul.products {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .woocommerce ul.products li.product .woocommerce-loop-product__title {
        font-size: 12px;
    }

    .woocommerce ul.products li.product .price {
        font-size: 13px;
    }

    .woocommerce ul.products li.product .button {
        font-size: 12px;
        padding: 8px;
    }

    h1 { font-size: 20px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }
}

/* ============================================
   PWA / STANDALONE MODE SUPPORT
   ============================================ */

@media all and (display-mode: standalone) {
    .site-header {
        padding-top: env(safe-area-inset-top);
    }

    .zigcy-mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================
   LANDSCAPE ORIENTATION
   ============================================ */

@media screen and (max-width: 768px) and (orientation: landscape) {
    .zigcy-mobile-bottom-nav {
        padding: 4px 0;
    }

    .zigcy-mobile-bottom-nav a {
        min-height: 36px;
        font-size: 9px;
    }

    body {
        padding-bottom: 55px;
    }
}
