/**
 * Mobile Responsive Styles for BestTopPrint
 * Optimized for iPhone devices (portrait and landscape)
 */

/* ========================================
   MOBILE MENU TOGGLE BUTTON (HAMBURGER)
   ======================================== */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* Category menu overlay for mobile */
.category-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   MEDIA QUERIES - MOBILE PORTRAIT
   iPhone SE: 375px, iPhone 12/13/14: 390px,
   iPhone 14 Pro Max: 428px
   ======================================== */

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

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ========================================
       HEADER ADJUSTMENTS
       ======================================== */

    header .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    header .flex {
        flex-wrap: wrap;
    }

    /* Logo smaller on mobile */
    header img {
        height: 32px !important;
    }

    /* User menu adjustments */
    header .flex.items-center.space-x-4 {
        gap: 0.5rem;
    }

    header .flex.items-center.space-x-4 > * {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* Hide session timer on very small screens */
    #session-timer {
        display: none;
    }

    @media only screen and (min-width: 390px) {
        #session-timer {
            display: inline;
        }
    }

    /* Stack buttons on smaller screens */
    @media only screen and (max-width: 390px) {
        header .flex.items-center.space-x-4 {
            width: 100%;
            margin-top: 0.5rem;
            justify-content: flex-end;
        }
    }

    /* ========================================
       HERO SECTION
       ======================================== */

    .gradient-bg {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .gradient-bg h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.3;
    }

    .gradient-bg p {
        font-size: 0.875rem !important;
        margin-bottom: 1rem !important;
    }

    /* ========================================
       NAVIGATION MENU (O nas, Realizacje, etc.)
       ======================================== */

    .gradient-bg nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    .gradient-bg nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .gradient-bg nav ul {
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .nav-menu-item {
        padding: 0.5rem 1rem !important;
        font-size: 0.8125rem !important;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ========================================
       MAIN CONTENT LAYOUT
       ======================================== */

    section.max-w-7xl {
        padding: 1rem !important;
    }

    section.max-w-7xl > .flex {
        flex-direction: column;
        gap: 0;
    }

    /* ========================================
       SIDEBAR - CATEGORIES (HAMBURGER MENU)
       ======================================== */

    /* Hide desktop sidebar, show mobile hamburger menu */
    aside.w-64 {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100%;
        z-index: 999;
        transition: left 0.3s ease;
        overflow-y: auto;
        background: white;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    aside.w-64.active {
        left: 0;
    }

    aside.w-64 > div {
        height: 100%;
        border-radius: 0;
        border: none;
        border-right: 1px solid #e5e7eb;
    }

    /* Close button for mobile menu */
    .mobile-menu-close {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: #f3f4f6;
        border: none;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        cursor: pointer;
        z-index: 10;
    }

    .mobile-menu-close svg {
        width: 20px;
        height: 20px;
    }

    /* Add padding top for close button */
    aside.w-64 h3 {
        padding-top: 0.5rem;
    }

    /* ========================================
       FILTERS SECTION
       ======================================== */

    .bg-white.rounded-lg.shadow-sm.border.p-4.mb-6 .flex {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch !important;
    }

    .bg-white.rounded-lg.shadow-sm.border.p-4.mb-6 .flex-1 {
        max-width: 100% !important;
    }

    .bg-white.rounded-lg.shadow-sm.border.p-4.mb-6 .flex.items-center.gap-2 {
        flex-direction: row;
        width: 100%;
    }

    .bg-white.rounded-lg.shadow-sm.border.p-4.mb-6 label {
        font-size: 0.75rem;
    }

    #sort-select {
        flex: 1;
        font-size: 0.875rem;
    }

    .bg-white.rounded-lg.shadow-sm.border.p-4.mb-6 button {
        width: 100%;
        font-size: 0.875rem;
    }

    /* Search input */
    #search-input {
        font-size: 0.875rem;
        padding: 0.625rem 1rem !important;
    }

    /* ========================================
       PRODUCTS GRID
       ======================================== */

    #products-container {
        margin-bottom: 1.5rem !important;
    }

    /* Products grid - single column on mobile */
    #products-container > div[class*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Product card adjustments */
    .product-card {
        max-width: 100%;
    }

    .product-card:hover {
        transform: translateY(-2px) !important;
    }

    .product-image {
        height: 180px !important;
    }

    /* Category description on mobile */
    .category-description {
        margin-bottom: 1rem;
    }

    .category-description-content {
        padding: 0.75rem 1rem;
    }

    .category-description-text {
        font-size: 0.8125rem;
    }

    /* ========================================
       PAGINATION
       ======================================== */

    #pagination-container {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    #pagination-container button,
    #pagination-container a {
        min-width: 40px;
        height: 40px;
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    /* Hide page numbers on very small screens, keep only prev/next */
    @media only screen and (max-width: 375px) {
        #pagination-container button:not(:first-child):not(:last-child) {
            display: none;
        }

        #pagination-container button:first-child,
        #pagination-container button:last-child {
            flex: 1;
            max-width: 120px;
        }
    }

    /* ========================================
       FOOTER
       ======================================== */

    footer .flex {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    footer .flex.space-x-6 {
        flex-direction: row;
        justify-content: center;
        gap: 1.5rem;
    }

    /* ========================================
       AUTH MODAL
       ======================================== */

    #authModal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    #authModal .modal-header h3 {
        font-size: 1.25rem;
    }

    #authModal .modal-body {
        padding: 1.5rem 1rem;
    }

    #authModal input {
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem !important;
    }

    #authModal button[type="submit"] {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem;
    }

    /* Tab buttons */
    #authModal .flex button {
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem !important;
    }

    /* VAT search button */
    #authModal button[onclick="searchVat()"] {
        padding: 0.625rem 0.875rem !important;
        font-size: 0.8125rem;
    }
}

/* ========================================
   MEDIA QUERIES - MOBILE LANDSCAPE
   iPhone in landscape mode
   ======================================== */

@media only screen and (max-width: 926px) and (orientation: landscape) {

    /* Reduce hero section padding in landscape */
    .gradient-bg {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .gradient-bg h2 {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
    }

    .gradient-bg p {
        font-size: 0.8125rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Navigation menu more compact */
    .nav-menu-item {
        padding: 0.375rem 0.875rem !important;
        font-size: 0.75rem !important;
    }

    /* Sidebar full height */
    aside.w-64 {
        height: 100vh;
    }

    /* Product grid - 2 columns in landscape */
    #products-container > div[class*="grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .product-image {
        height: 150px !important;
    }

    /* Modal adjustments for landscape */
    #authModal .modal-content {
        max-height: 85vh;
    }
}

/* ========================================
   MEDIA QUERIES - TABLET (768px - 1024px)
   iPad and similar devices
   ======================================== */

@media only screen and (min-width: 769px) and (max-width: 1024px) {

    /* Hide mobile menu toggle on tablet */
    .mobile-menu-toggle {
        display: none;
    }

    /* Sidebar visible on tablet */
    aside.w-64 {
        position: relative;
        left: 0;
        width: 240px;
    }

    /* Products grid - 2 columns on tablet */
    #products-container > div[class*="grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Navigation menu */
    .nav-menu-item {
        padding: 0.625rem 1.25rem !important;
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   SPECIFIC IPHONE MODELS
   ======================================== */

/* iPhone SE (375px) */
@media only screen and (max-width: 375px) {

    header img {
        height: 28px !important;
    }

    .gradient-bg h2 {
        font-size: 1.25rem !important;
    }

    .product-image {
        height: 160px !important;
    }

    aside.w-64 {
        width: 260px;
        left: -260px;
    }
}

/* iPhone 12/13/14 Pro Max (428px) */
@media only screen and (min-width: 428px) and (max-width: 768px) {

    /* Products grid - 2 columns on larger phones */
    #products-container > div[class*="grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.875rem !important;
    }

    .product-image {
        height: 160px !important;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

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

    .mobile-hidden {
        display: none !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }

    .mobile-text-center {
        text-align: center !important;
    }

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

    .mobile-m-0 {
        margin: 0 !important;
    }
}

/* ========================================
   SMOOTH SCROLLING
   ======================================== */

html {
    scroll-behavior: smooth;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
}

/* ========================================
   TOUCH IMPROVEMENTS
   ======================================== */

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

    /* Increase touch targets */
    button, a, .category-item, .subcategory-item {
        min-height: 44px;
        /* Removed display: flex to avoid breaking inline-flex buttons */
    }

    /* Better tap highlighting */
    * {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }

    /* Prevent text selection on double tap */
    .category-header, .nav-menu-item, button {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ========================================
   PRODUCT "ZAMÓW" BUTTONS - REDUCE HEIGHT
   ======================================== */

/* Reduce vertical padding on "Zamów" buttons for all screen sizes */
.product-card button.gradient-bg,
button.gradient-bg {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}
