/* ============================================================
   PAWFINITY — MOBILE PRO ENHANCEMENTS
   Applied on top of existing CSS. Desktop styles untouched.
   Breakpoints: 768px (tablet), 640px (large mobile), 480px (mobile),
   380px (small mobile)
   Updated: 2026-04-16
   ============================================================ */

/* Global safety — prevent horizontal overflow caused by any rogue element */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

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

/* Respect notch / safe areas on iOS */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================================
   HEADER & MOBILE NAVIGATION
   ============================================================ */
@media (max-width: 768px) {
    .header,
    header.header,
    .main-header {
        height: 60px !important;
        padding: 0 !important;
    }

    .header .container,
    .header-content {
        padding: 0 14px !important;
        gap: 8px !important;
    }

    /* Logo compact on mobile */
    .logo h1,
    .logo a h1 {
        font-size: 1.15rem !important;
    }
    .logo i,
    .logo a i {
        font-size: 1.15rem !important;
    }

    /* Hide desktop nav / search on mobile — rely on mobile menu */
    .nav,
    .main-nav,
    .nav-list,
    .header .search-box {
        display: none !important;
    }

    .header-actions {
        gap: 6px !important;
    }

    .cart-icon,
    #cartIcon {
        width: 40px !important;
        height: 40px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        border-radius: 10px !important;
        position: relative !important;
    }

    .cart-count {
        min-width: 18px !important;
        height: 18px !important;
        font-size: 0.65rem !important;
        line-height: 18px !important;
        padding: 0 5px !important;
        top: -2px !important;
        right: -2px !important;
    }

    .mobile-menu-toggle {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        color: #111 !important;
        font-size: 1.25rem !important;
        border-radius: 10px !important;
    }

    .mobile-menu-toggle:active {
        background: #f3f4f6 !important;
    }

    /* Push content below the fixed header */
    body {
        padding-top: 60px !important;
    }
}

/* ============================================================
   HERO — New Reference-Style Section
   ============================================================ */
@media (max-width: 1024px) {
    .hero-3d {
        min-height: auto !important;
        padding: 24px 0 40px !important;
        margin-top: 0 !important;
    }

    .hero-container {
        grid-template-columns: 1fr !important;
        padding: 32px 20px 16px !important;
        gap: 24px !important;
        text-align: center !important;
    }

    .hero-content {
        align-items: center !important;
    }

    .hero-visual {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .hero-3d {
        padding: 16px 0 36px !important;
    }

    .hero-container {
        padding: 24px 18px 8px !important;
        gap: 18px !important;
    }

    .hero-badge {
        margin: 0 auto 8px !important;
    }

    .hero-badge-text {
        font-size: 0.7rem !important;
        letter-spacing: 0.12em !important;
    }

    .hero-title {
        font-size: 2.25rem !important;
        line-height: 1.12 !important;
        margin-bottom: 16px !important;
        padding: 0 8px !important;
    }

    .hero-title .highlight {
        display: inline !important;
    }

    .hero-description {
        font-size: 0.98rem !important;
        line-height: 1.55 !important;
        margin: 0 auto 24px !important;
        max-width: 100% !important;
        padding: 0 10px !important;
        color: #d1d5db !important;
    }

    .hero-buttons {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
        padding: 0 14px !important;
        margin-bottom: 0 !important;
    }

    .hero-btn-primary,
    .hero-btn-secondary {
        width: 100% !important;
        padding: 15px 22px !important;
        font-size: 1rem !important;
        border-radius: 9999px !important;
    }

    /* Simplify heavy background effects on mobile for performance */
    .hero-grid {
        opacity: 0.15 !important;
    }
    .floating-orb,
    .ring-3d,
    .floating-card {
        display: none !important;
    }

    /* Legacy feature strip */
    .hero-features {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 12px 16px 24px !important;
    }

    .hero-feature {
        padding: 12px 14px !important;
        border-radius: 12px !important;
    }

    .hero-feature-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.95rem !important;
    }

    .hero-feature-text span {
        font-size: 0.92rem !important;
    }

    .hero-feature-text small {
        font-size: 0.75rem !important;
    }
}

@media (max-width: 380px) {
    .hero-title {
        font-size: 1.95rem !important;
    }

    .hero-description {
        font-size: 0.92rem !important;
    }
}

/* ============================================================
   REFERENCE SECTIONS — Featured Products / Categories / Features / CTA
   ============================================================ */
@media (max-width: 768px) {
    .ref-section,
    .ref-fp-section {
        padding: 44px 0 !important;
    }

    .ref-container {
        padding: 0 18px !important;
    }

    .ref-section-header {
        margin-bottom: 28px !important;
    }

    .ref-h2 {
        font-size: 1.55rem !important;
        margin-bottom: 10px !important;
        line-height: 1.25 !important;
    }

    .ref-subtext {
        font-size: 0.95rem !important;
        line-height: 1.55 !important;
        padding: 0 6px !important;
    }
}

/* Featured Products — 2 columns on small tablets, full width on phones */
@media (max-width: 640px) {
    .ref-fp-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }

    .ref-fp-img-wrap {
        height: 160px !important;
    }

    .ref-fp-body {
        padding: 14px !important;
        gap: 6px !important;
    }

    .ref-fp-category {
        font-size: 0.75rem !important;
    }

    .ref-fp-name {
        font-size: 0.95rem !important;
        line-height: 1.3 !important;
    }

    .ref-fp-stars { gap: 6px !important; }
    .ref-fp-star-row { font-size: 0.72rem !important; }
    .ref-fp-review-count { font-size: 0.72rem !important; }

    .ref-fp-footer {
        padding-top: 6px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .ref-fp-price {
        font-size: 1.1rem !important;
    }

    .ref-fp-add-btn {
        padding: 7px 14px !important;
        font-size: 0.82rem !important;
        border-radius: 8px !important;
    }

    .ref-fp-badge {
        top: 10px !important;
        right: 10px !important;
        font-size: 0.7rem !important;
        padding: 3px 9px !important;
    }
}

@media (max-width: 380px) {
    .ref-fp-grid {
        grid-template-columns: 1fr !important;
    }
    .ref-fp-img-wrap {
        height: 200px !important;
    }
}

/* Shop by Pet Type — reference cat cards */
@media (max-width: 768px) {
    .ref-cat-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .ref-cat-img-wrap {
        height: 240px !important;
    }

    .ref-cat-content {
        padding: 20px !important;
    }

    .ref-cat-content h3 {
        font-size: 1.35rem !important;
        margin-bottom: 8px !important;
    }

    .ref-cat-content p {
        font-size: 0.88rem !important;
        line-height: 1.55 !important;
        margin-bottom: 12px !important;
    }

    .ref-cat-btn {
        padding: 8px 20px !important;
        font-size: 0.85rem !important;
    }
}

/* Why Choose — feature cards */
@media (max-width: 768px) {
    .ref-features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }

    .ref-feature-icon {
        width: 64px !important;
        height: 64px !important;
        font-size: 1.35rem !important;
        margin-bottom: 16px !important;
    }

    .ref-feature-title {
        font-size: 1rem !important;
        margin-bottom: 8px !important;
    }

    .ref-feature-text {
        font-size: 0.85rem !important;
    }
}

@media (max-width: 380px) {
    .ref-features-grid {
        grid-template-columns: 1fr !important;
    }
}

/* CTA Section */
@media (max-width: 768px) {
    .ref-cta-section {
        padding: 48px 0 !important;
    }

    .ref-cta-inner {
        padding: 0 18px !important;
    }

    .ref-cta-title {
        font-size: 1.65rem !important;
        margin-bottom: 14px !important;
    }

    .ref-cta-text {
        font-size: 0.95rem !important;
        line-height: 1.55 !important;
        margin-bottom: 22px !important;
    }

    .ref-cta-btn {
        padding: 14px 26px !important;
        font-size: 0.98rem !important;
        width: 100% !important;
        max-width: 320px !important;
        justify-content: center !important;
    }
}

/* ============================================================
   FOOTER — Reference-Exact Footer Mobile
   ============================================================ */
@media (max-width: 768px) {
    .ref-footer {
        padding: 36px 0 0 !important;
    }

    .ref-footer-grid {
        grid-template-columns: 1fr !important;
        gap: 26px !important;
        padding-bottom: 24px !important;
    }

    .ref-footer-brand {
        gap: 12px !important;
    }

    .ref-footer-tagline {
        max-width: 100% !important;
        font-size: 0.88rem !important;
    }

    .ref-footer-social {
        justify-content: flex-start !important;
    }

    .ref-social-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem !important;
    }

    .ref-footer-heading {
        font-size: 0.82rem !important;
    }

    .ref-footer-links a,
    .ref-footer-contact {
        font-size: 0.88rem !important;
    }

    .ref-footer-bottom {
        padding: 18px 0 !important;
        gap: 8px !important;
    }

    .ref-footer-bottom p,
    .ref-footer-legal a {
        font-size: 0.78rem !important;
    }

    .ref-footer-legal {
        gap: 16px !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
}

/* Legacy footer fallback */
@media (max-width: 768px) {
    .footer {
        padding: 36px 0 16px !important;
    }

    .footer-content,
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 26px !important;
        padding: 0 18px !important;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 0.95rem !important;
    }

    .footer-section a {
        font-size: 0.88rem !important;
    }

    .footer-bottom {
        padding: 16px 18px 0 !important;
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
        font-size: 0.78rem !important;
    }
}

/* ============================================================
   PRODUCTS PAGE — Mobile
   ============================================================ */
@media (max-width: 768px) {
    .products-hero {
        height: auto !important;
        min-height: 320px !important;
        margin-top: 60px !important;
    }

    .products-hero-content {
        padding: 48px 18px !important;
    }

    .products-hero-badge {
        font-size: 0.72rem !important;
        padding: 6px 14px !important;
        margin-bottom: 14px !important;
    }

    .products-hero-title {
        font-size: 2rem !important;
        margin-bottom: 12px !important;
    }

    .products-hero-subtitle {
        font-size: 0.95rem !important;
        margin-bottom: 20px !important;
        padding: 0 4px !important;
    }

    .products-hero-pills {
        gap: 8px !important;
    }

    .products-hero-pill {
        padding: 7px 14px !important;
        font-size: 0.78rem !important;
    }

    .products-section {
        padding: 36px 0 !important;
    }

    .products-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        margin-bottom: 20px !important;
        padding: 0 16px !important;
    }

    .products-header h2 {
        font-size: 1.25rem !important;
        text-align: center !important;
    }

    .products-filters {
        gap: 8px !important;
        width: 100% !important;
    }

    .filter-select {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 0 12px !important;
    }

    .product-card {
        border-radius: 12px !important;
    }

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

    .product-card h3,
    .product-card .product-title {
        font-size: 0.9rem !important;
        line-height: 1.3 !important;
    }

    .product-card .product-price {
        font-size: 1rem !important;
    }

    .product-card .add-to-cart,
    .product-card button {
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
    }
}

@media (max-width: 380px) {
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    .product-card .product-image,
    .product-card img {
        height: 220px !important;
    }
}

/* ============================================================
   PRODUCT DETAIL PAGE — Mobile
   ============================================================ */
@media (max-width: 768px) {
    .product-grid {
        gap: 0 !important;
    }

    .main-image-wrap {
        aspect-ratio: 1 !important;
        border-radius: 0 !important;
    }

    .thumb-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 8px !important;
        padding: 0 16px !important;
    }

    .product-info {
        padding: 16px 18px 100px !important;
    }

    .product-info h1,
    .product-title {
        font-size: 1.35rem !important;
        line-height: 1.25 !important;
    }

    .product-price,
    .price-display {
        font-size: 1.5rem !important;
    }

    /* Sticky add-to-cart bottom bar on product pages */
    .add-to-cart-bar,
    .sticky-cta-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        background: #ffffff !important;
        border-top: 1px solid #e5e7eb !important;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06) !important;
    }

    .quantity-selector {
        gap: 8px !important;
    }

    .quantity-btn {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ============================================================
   CART PAGE — Mobile
   ============================================================ */
@media (max-width: 900px) {
    .cart-layout {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }
}

@media (max-width: 768px) {
    .cart-hero {
        padding: 74px 0 20px !important;
    }

    .cart-hero-content {
        padding: 0 16px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }

    .cart-hero h1 {
        font-size: 1.35rem !important;
    }

    .cart-breadcrumb {
        font-size: 0.8rem !important;
    }

    .cart-section {
        padding: 20px 0 40px !important;
    }

    .cart-layout {
        padding: 0 14px !important;
    }

    .cart-card-header {
        padding: 14px 16px !important;
    }

    .cart-item {
        grid-template-columns: 72px 1fr !important;
        grid-template-rows: auto auto !important;
        padding: 14px 16px !important;
        gap: 12px !important;
    }

    .cart-item-image {
        width: 72px !important;
        height: 72px !important;
        grid-row: span 2 !important;
    }

    .cart-item-details h4 {
        font-size: 0.92rem !important;
    }

    .cart-item-meta {
        font-size: 0.78rem !important;
    }

    .cart-item-actions,
    .cart-item-controls {
        grid-column: 2 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-top: 4px !important;
    }

    .cart-item-price,
    .cart-item-total {
        font-size: 0.95rem !important;
        font-weight: 600 !important;
    }

    .summary-card,
    .cart-summary-card {
        position: static !important;
        width: 100% !important;
    }

    .checkout-btn {
        width: 100% !important;
        padding: 14px !important;
        font-size: 1rem !important;
    }
}

/* ============================================================
   CHECKOUT PAGE — Mobile
   ============================================================ */
@media (max-width: 900px) {
    .checkout-grid,
    .checkout-layout {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }
}

@media (max-width: 768px) {
    .checkout-section,
    .checkout-container {
        padding: 16px !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* prevents iOS zoom */
        padding: 12px 14px !important;
        width: 100% !important;
        border-radius: 10px !important;
    }

    .form-group label {
        font-size: 0.88rem !important;
    }

    .order-summary-card {
        position: static !important;
    }

    .place-order-btn,
    .btn-primary {
        width: 100% !important;
        padding: 14px !important;
        font-size: 1rem !important;
    }
}

/* ============================================================
   CATEGORY PAGES (dogs / cats / small-pets / health)
   ============================================================ */
@media (max-width: 768px) {
    .category-hero {
        padding: 74px 16px 24px !important;
        text-align: center !important;
    }

    .category-hero h1 {
        font-size: 1.6rem !important;
        margin-bottom: 8px !important;
    }

    .category-hero p {
        font-size: 0.92rem !important;
        line-height: 1.55 !important;
    }

    .category-products,
    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 0 14px !important;
    }
}

@media (max-width: 380px) {
    .category-products,
    .category-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================
   FORMS — Global Mobile Form Friendliness
   ============================================================ */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;           /* Avoid iOS auto-zoom */
        border-radius: 10px !important;
        padding: 12px 14px !important;
    }

    button,
    .btn,
    a.btn {
        min-height: 44px !important;          /* Apple HIG touch target */
    }
}

/* ============================================================
   COOKIE CONSENT / AI CHAT — Mobile
   ============================================================ */
@media (max-width: 640px) {
    .cookie-consent-banner,
    .cookie-consent {
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        width: auto !important;
        max-width: none !important;
        padding: 14px !important;
        border-radius: 14px !important;
    }

    .cookie-consent-actions,
    .cookie-buttons {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .cookie-consent button {
        width: 100% !important;
    }

    .ai-chat-widget,
    .chat-widget {
        bottom: 14px !important;
        right: 14px !important;
    }

    .ai-chat-window,
    .chat-window {
        width: calc(100vw - 24px) !important;
        max-width: none !important;
        height: 70vh !important;
        right: 12px !important;
        bottom: 70px !important;
        border-radius: 14px !important;
    }
}

/* ============================================================
   SECTION SPACING & TYPOGRAPHY DEFAULTS ON MOBILE
   ============================================================ */
@media (max-width: 768px) {
    section {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    h1 { font-size: clamp(1.5rem, 6vw, 2rem) !important; }
    h2 { font-size: clamp(1.25rem, 5vw, 1.75rem) !important; }
    h3 { font-size: clamp(1.05rem, 4.2vw, 1.35rem) !important; }
}
