/* ===================================
   SaaSrat - Shared Responsive Styles
   =================================== */

/* Base responsive adjustments */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent horizontal scroll on mobile */
body {
    overflow-x: hidden;
}

/* ===================================
   Header Responsive
   =================================== */

/* Ensure dropdown doesn't overflow on smaller desktops */
@media (min-width: 768px) and (max-width: 1024px) {
    .group:hover .absolute {
        left: auto;
        right: 0;
    }
}

/* Mobile menu animations */
#mobile-menu {
    transition: max-height 0.3s ease-out;
}

#mobile-categories-icon {
    transition: transform 0.2s ease;
}

#mobile-categories-icon.rotate-180 {
    transform: rotate(180deg);
}

/* ===================================
   Typography Responsive
   =================================== */

/* Heading scales */
@media (max-width: 640px) {
    .text-4xl { font-size: 1.75rem; line-height: 2rem; }
    .text-5xl { font-size: 2rem; line-height: 2.25rem; }
    .text-6xl { font-size: 2.25rem; line-height: 2.5rem; }
}

@media (min-width: 641px) and (max-width: 768px) {
    .text-4xl { font-size: 2rem; line-height: 2.25rem; }
    .text-5xl { font-size: 2.5rem; line-height: 2.75rem; }
    .text-6xl { font-size: 3rem; line-height: 3.25rem; }
}

/* ===================================
   Card Responsive
   =================================== */

.card-hover {
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .card-hover:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .card-hover:hover {
        transform: none;
    }
    
    .card-hover:active {
        transform: scale(0.98);
    }
}

/* ===================================
   Grid Responsive
   =================================== */

/* Product grid adjustments for very small screens */
@media (max-width: 359px) {
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   Button Responsive
   =================================== */

/* Full-width buttons on mobile */
@media (max-width: 640px) {
    .btn-responsive {
        width: 100%;
        justify-content: center;
    }
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {
    button:not(.text-btn),
    a.btn,
    .popular-btn,
    #mobile-filter-toggle,
    #apply-filters {
        min-height: 44px;
    }
    
    /* Exception for inline links */
    p a, li a, span a, .inline-link {
        min-height: auto;
        min-width: auto;
    }
}

/* ===================================
   Search Autocomplete Responsive
   =================================== */

.autocomplete-suggestions {
    max-width: calc(100vw - 32px);
}

@media (max-width: 640px) {
    .autocomplete-suggestions {
        position: fixed !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        max-height: 60vh;
    }
    
    .autocomplete-suggestion {
        padding: 14px 16px;
    }
    
    .autocomplete-item img {
        width: 36px;
        height: 36px;
    }
}

/* ===================================
   Footer Responsive
   =================================== */

@media (max-width: 640px) {
    footer .grid {
        gap: 1.5rem;
    }
    
    footer h4 {
        font-size: 0.875rem;
    }
    
    footer ul {
        font-size: 0.8125rem;
    }
}

/* ===================================
   Category Page Specific
   =================================== */

/* Filter sidebar mobile */
@media (max-width: 1023px) {
    #filter-sidebar.fixed {
        position: fixed !important;
        inset: 0 !important;
        z-index: 50 !important;
        background: white !important;
        overflow-y: auto !important;
        padding: 16px !important;
    }
}

/* Sort select mobile */
@media (max-width: 480px) {
    #sort-select {
        font-size: 14px;
        padding: 10px 12px;
    }
}

/* Breadcrumb text truncation on small screens */
@media (max-width: 400px) {
    .line-clamp-1 {
        max-width: 120px;
    }
}

/* ===================================
   Safe Areas (for notched phones)
   =================================== */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
    
    /* Filter sidebar safe areas */
    #filter-sidebar.fixed {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    header, footer, #mobile-menu, .no-print,
    #mobile-filter-toggle, #filter-sidebar {
        display: none !important;
    }
    
    main {
        padding: 0 !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ===================================
   Reduced Motion
   =================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ===================================
   Focus States (Accessibility)
   =================================== */

:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ===================================
   Scrollbar Styling
   =================================== */

/* Hide scrollbar on horizontal scroll containers */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Custom scrollbar for filter sidebar on desktop */
@media (min-width: 1024px) {
    #filter-sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    #filter-sidebar::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 3px;
    }
    
    #filter-sidebar::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
    }
    
    #filter-sidebar::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}