/* SmartHomewareservice Responsive Premium Overrides */

/* --- Mobile View Transitions --- */
@media (max-width: 991.98px) {
    .nav-menu {
        backdrop-filter: blur(20px);
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid var(--border);
        transform-origin: top center;
    }

    .nav-menu.show {
        animation: premiumFadeDown 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    }

    .mobile-toggle {
        display: flex;
    }
}

@keyframes premiumFadeDown {
    0% {
        opacity: 0;
        transform: scaleY(0.9);
    }

    100% {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* =========================================
   Mobile Devices (< 768px)
   ========================================= */
@media (max-width: 767.98px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    /* Typography */
    h1 {
        font-size: 2.25rem;
        letter-spacing: -0.04em;
    }

    h2,
    .section-header h2,
    .section-categories .section-header h2,
    .section-products .section-header h2 {
        font-size: 0.9rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.05em !important;
        margin-bottom: 0.5rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 800;
        opacity: 0.9;
        background: none !important;
        -webkit-text-fill-color: var(--text) !important;
    }

    .section {
        padding: 1.5rem 0;
    }

    .section-header {
        margin-bottom: 1.5rem;
    }

    .section-header p {
        font-size: 0.85rem;
        margin-top: 0.5rem;
        line-height: 1.4;
    }

    /* Hero Slider */
    .hero-slider {
        height: 220px;
        border-radius: 0;
    }

    .slide-content {
        text-align: center;
    }

    .slide-content h1 {
        font-size: 1rem;
        max-width: 100%;
        margin-bottom: 0.2rem;
        letter-spacing: -0.01em;
    }

    .slide-content p {
        font-size: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 0.75rem;
        line-height: 1.3;
        opacity: 0.9;
    }

    .slider-prev,
    .slider-next {
        display: none;
    }

    /* Hide arrows on small mobile for clean look */
    .slider-dots {
        bottom: 1.5rem;
    }

    /* Navigation */
    .logo {
        font-size: 1.15rem;
        /* Slightly smaller for better fit */
        white-space: nowrap;
        gap: 0.4rem;
        /* Reduced gap */
        flex-shrink: 1;
        /* Allow logo to shrink if needed */
        min-width: 0;
        /* Important for flex-shrink */
    }

    .logo-text {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .logo-desktop {
        display: none;
    }

    .logo-mobile {
        display: inline;
    }

    .nav-actions {
        gap: 0.4rem;
        /* Reduced gap between icons */
        flex-shrink: 0;
        /* Keep icons visible */
    }

    .nav-icon {
        width: 32px;
        /* Smaller icons on mobile */
        height: 32px;
        font-size: 1.1rem;
    }

    .desktop-only-icon {
        display: none !important;
    }

    .mobile-only-item {
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
    }

    .mobile-only-item.separator {
        height: 1px;
        background: rgba(255, 255, 255, 0.1);
        margin: 1rem 0;
        display: block !important;
        width: 100%;
    }

    .mobile-only-item a {
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
        padding: 0.8rem 1rem;
        color: var(--text) !important;
        width: 100%;
        font-weight: 600;
        border-radius: var(--radius);
        transition: var(--transition);
    }

    .mobile-only-item a:hover {
        background: var(--primary-light);
        color: var(--primary) !important;
        padding-left: 1.5rem;
    }

    .mobile-only-item a i {
        width: 20px;
        text-align: center;
        color: var(--primary);
    }

    .mobile-only-item.logout-link a {
        color: #ef4444 !important;
    }

    .mobile-only-item.logout-link a i {
        color: #ef4444 !important;
    }

    .mobile-only-item.logout-link a:hover {
        background: rgba(239, 68, 68, 0.1);
    }

    /* Ultra-small devices */
    @media (max-width: 360px) {
        .logo {
            font-size: 1.05rem;
            gap: 0.25rem;
        }

        .nav-actions {
            gap: 0.25rem;
        }

        .nav-icon {
            width: 28px;
            height: 28px;
            font-size: 1rem;
        }
    }

    /* Next-level responsiveness for ultra-narrow phones (e.g. 250px) */
    @media (max-width: 300px) {
        .container {
            padding-left: 0.75rem;
            padding-right: 0.75rem;
        }

        h1 {
            font-size: 1.75rem;
        }

        h2 {
            font-size: 1.5rem;
        }

        .logo {
            font-size: 0.95rem;
            gap: 0.2rem;
        }

        .nav-actions {
            gap: 0.15rem;
        }

        .nav-icon {
            width: 24px;
            height: 24px;
            font-size: 0.85rem;
        }

        .cart-badge {
            font-size: 0.6rem;
            padding: 1px 4px;
            top: 0;
            right: 0;
        }

        .mobile-toggle {
            padding: 0.35rem;
            font-size: 1rem;
        }

        .slide-content h1 {
            font-size: 1.8rem;
        }

        .hero-slider {
            height: 200px;
        }

        .product-info h3 {
            font-size: 1rem;
        }

        .product-price {
            font-size: 1.2rem;
        }

        .section {
            padding: 3rem 0;
        }

        .categories-grid {
            grid-template-columns: 1fr;
            gap: 1rem;
        }
    }

    /* Grids - Optimized for Mobile */
    .categories-grid,
    .products-grid,
    .services-grid,
    .clients-page-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        /* Minimal gap */
        padding-left: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Compact Images for Mobile - Perfect Box Look */
    .category-image img,
    .category-card img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        /* Fill box completely */
        border-radius: 8px;
        /* Soften edges */
    }

    .category-image {
        height: 100px !important;
        /* Fixed Uniform Height */
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 0.5rem;
        overflow: hidden;
    }

    .product-image img,
    .product-card img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        /* Fill box completely */
        margin: 0 !important;
    }

    .product-image {
        height: 110px !important;
        /* Fixed Uniform Height (Reduced) */
        width: 100% !important;
        padding: 0 !important;
        display: block !important;
        /* Remove flex centering to allow full fill */
        background: #f8fafc;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        overflow: hidden;
    }

    .member-image-wrapper {
        padding-top: 0 !important;
        height: 180px !important;
        /* Fixed uniform height */
        border-radius: 12px 12px 0 0;
        overflow: hidden;
    }

    .member-image-wrapper img {
        height: 100% !important;
        width: 100% !important;
        object-fit: cover !important;
    }

    .member-info {
        padding: 0.5rem !important;
        /* More compact team cards too */
    }

    .member-info h3 {
        font-size: 0.95rem !important;
        margin-bottom: 0.1rem !important;
    }

    .member-role {
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    .service-icon i {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem;
    }

    .product-card {
        border-radius: 12px !important;
    }

    .product-info {
        padding: 0.4rem 0.5rem !important;
        /* Aggressively reduced padding */
        display: flex !important;
        flex-direction: column !important;
        gap: 0.15rem;
        /* Tighter gap */
        flex-grow: 1;
        /* Ensure it takes available space */
    }

    .product-info h3 {
        font-size: 0.85rem !important;
        /* Slightly smaller */
        margin: 0 !important;
        line-height: 1.1 !important;
        height: 2.2em;
        /* Shorter header height */
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .product-price {
        font-size: 0.9rem !important;
        /* Slightly smaller price */
        margin: 0 !important;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.25rem;
        margin-top: auto !important;
        /* Push to bottom */
        padding-top: 0.25rem;
        /* Reduced breathing room */
    }

    .price-old {
        font-size: 0.8rem !important;
    }

    .category-name {
        font-size: 0.6rem !important;
        margin-bottom: 2px !important;
    }

    @media (max-width: 480px) {
        .products-grid {
            grid-template-columns: repeat(2, 1fr) !important;
            gap: 0.5rem !important;
        }

        .product-info h3 {
            font-size: 1.1rem !important;
            height: auto;
            -webkit-line-clamp: unset;
            line-clamp: unset;
        }

        .product-price {
            font-size: 1.1rem !important;
        }

        .product-card .btn-sm {
            padding: 0.35rem 0.5rem !important;
            /* Smaller button padding */
            font-size: 0.75rem !important;
            /* Smaller button text */
        }
    }

    /* Forms */
    .auth-card {
        padding: 2.5rem 1.5rem;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        background: var(--white);
    }

    .auth-body {
        align-items: center;
        padding-top: 2rem;
    }

    /* Cart Mobile Optimization - Definitive Fix */
    .cart-layout,
    .cart-items,
    .cart-summary {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: block !important;
    }

    .cart-table {
        display: block !important;
        min-width: 0 !important;
        /* Forces layout to collapse */
        width: 100% !important;
        border: none !important;
    }

    .cart-table thead {
        display: none !important;
    }

    .cart-table tbody,
    .cart-table tr,
    .cart-table td {
        display: block !important;
        width: 100% !important;
    }

    .cart-table tr {
        margin-bottom: 2rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 1rem;
        /* Slightly reduced */
        background: var(--white);
        box-shadow: var(--shadow-sm);
        box-sizing: border-box !important;
    }

    .cart-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-light);
        text-align: right;
        gap: 1rem;
        white-space: normal !important;
    }

    .cart-table td:last-child {
        border-bottom: none;
        justify-content: center;
        padding-top: 1rem;
    }

    .cart-table td::before {
        content: attr(data-label);
        font-weight: 800;
        text-transform: uppercase;
        font-size: 0.7rem;
        color: var(--primary);
        text-align: left;
        min-width: 80px;
    }

    .cart-product-info {
        flex-direction: column;
        align-items: flex-end;
        text-align: right;
        gap: 0.5rem;
        max-width: 55%;
    }

    @media (max-width: 280px) {
        .cart-product-info {
            max-width: 45%;
            font-size: 0.85rem;
        }

        .cart-table td::before {
            min-width: 60px;
            font-size: 0.6rem;
        }
    }

    .cart-product-info img {
        width: 60px;
        height: 60px;
        margin-left: auto;
    }

    .cart-actions {
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    .cart-actions .btn {
        width: 100% !important;
        margin: 0 !important;
        text-align: center;
    }

    /* Newsletter Form Mobile Fix */
    .newsletter-form {
        flex-direction: column;
        gap: 1rem;
    }

    .newsletter-form .form-control {
        width: 100%;
        text-align: center;
    }

    .newsletter-form .btn {
        width: 100%;
    }

    /* --- Search Page Responsiveness --- */
    .search-header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: stretch;
        text-align: center;
    }

    .search-form input {
        width: 100%;
        flex: 1;
    }
}

/* =========================================
   Tablets (768px - 991px)
   ========================================= */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        padding-left: 2.5rem;
        padding-right: 2.5rem;
    }

    .hero-slider {
        height: 500px;
    }

    .slide-content h1 {
        font-size: 3rem;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================
   Desktops (>= 992px)
   ========================================= */
@media (min-width: 992px) {
    .navbar {
        padding: 1.5rem 0;
    }

    .nav-menu {
        display: flex;
        flex-direction: row;
        position: static;
        background: transparent;
        padding: 0;
        box-shadow: none;
        border: none;
        margin-top: 0;
        gap: 2rem;
    }

    .nav-menu li a {
        position: relative;
        padding: 0.5rem 0;
    }

    .nav-menu li a::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 0;
        height: 2px;
        background: var(--primary);
        transition: var(--transition);
    }

    .nav-menu li a:hover::after {
        width: 100%;
    }
}

/* --- Shop & Product Responsive --- */
@media (max-width: 767.98px) {
    .shop-layout {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .shop-sidebar {
        display: block;
    }

    .page-banner {
        padding: 4rem 0;
    }

    .page-banner h1 {
        font-size: 2.5rem;
    }

    .shop-header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: stretch;
    }

    .search-form input {
        width: 100%;
    }

    .product-layout {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .product-info-detail h1 {
        font-size: 2.25rem;
    }

    .product-price-lg {
        flex-wrap: wrap;
    }

    .product-price-lg .price-current {
        font-size: 2rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .tabs-nav {
        gap: 1.5rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .tab-btn {
        font-size: 0.95rem;
        white-space: nowrap;
    }
}

.product-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    align-items: start;
}

@media (min-width: 992px) {
    .product-layout {
        grid-template-columns: minmax(400px, 550px) 1fr;
        gap: 4rem;
    }
}

/* Tablet: 3 Column Grid for Shop */
.products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

@media (max-width: 991px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop Shop Layout - Categories sidebar visible */
.shop-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    align-items: start;
}

/* Ensure sidebar is visible on desktop */
.shop-sidebar {
    display: block;
    position: sticky;
    top: 100px;
}

/* Large screens: 4 columns for more compact product cards */
@media (min-width: 1200px) {
    .shop-layout {
        grid-template-columns: 280px 1fr;
        gap: 3.5rem;
    }

    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* Extra large screens: 4 columns */
@media (min-width: 1400px) {
    .shop-layout {
        grid-template-columns: 280px 1fr;
    }

    .products-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 1.5rem;
    }
}


/* =========================================
   Small Tablets / Large Phones (600px - 767px)
   ========================================= */
@media (max-width: 767.98px) {
    .shop-layout {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .shop-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        z-index: 1;
        margin-bottom: 0;
    }

    .shop-content {
        width: 100%;
    }

    /* Mobile: 2 Column Grid for Shop products (if width allows) */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .product-info {
        padding: 1.25rem;
    }

    .product-info h3 {
        font-size: 1.1rem;
    }

    .price-current {
        font-size: 1.2rem;
    }
}

/* Redundant overrides removed to prevent scattering */

@media (max-width: 991.98px) {

    .checkout-layout,
    .contact-layout {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .order-summary {
        position: static;
        width: 100%;
    }

    .contact-info {
        text-align: center;
        max-width: 800px;
        margin: 0 auto;
    }

    .info-cards {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .info-card {
        text-align: left;
    }

    .social-links {
        justify-content: center;
    }
}

@media (max-width: 767.98px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .checkout-section {
        padding: 1.5rem;
    }

    .contact-form-wrapper {
        padding: 2rem;
    }
}

/* --- Contact Page Mobile Refinements --- */
@media (max-width: 767.98px) {
    .contact-form-wrapper {
        padding: 2.5rem 1.5rem !important;
    }

    .login-prompt-box {
        width: 92% !important;
        padding: 2.5rem 1.5rem !important;
    }

    .form-row {
        gap: 0 !important;
    }
}

@media (max-width: 480px) {
    .info-cards {
        grid-template-columns: 1fr !important;
    }

    .info-card {
        flex-direction: column !important;
        text-align: center !important;
        padding: 2rem 1rem !important;
    }

    .info-icon {
        margin: 0 auto !important;
    }

    .page-banner {
        padding: 3.5rem 0 !important;
    }

    .page-banner h1 {
        font-size: 2.25rem !important;
    }
}

/* --- Footer Mobile Optimization --- */
@media (max-width: 767.98px) {
    .footer {
        padding-top: 3rem !important;
        padding-bottom: 2rem !important;
        text-align: center !important;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        margin-bottom: 2.5rem !important;
    }

    .footer-brand-col {
        align-items: center !important;
        text-align: center !important;
        gap: 1rem !important;
    }

    .footer-logo {
        justify-content: center !important;
        margin-bottom: 0.5rem !important;
    }

    .footer-desc {
        max-width: 100% !important;
        margin: 0 auto !important;
        text-align: center !important;
    }

    .footer-social {
        justify-content: center !important;
        margin-top: 0.5rem !important;
    }

    .footer-col {
        text-align: center !important;
    }

    .footer-col h4 {
        margin-bottom: 1rem !important;
        display: inline-block !important;
        position: relative;
    }

    .footer-col h4::after {
        margin: 0.5rem auto 0 !important;
    }

    .footer-col ul {
        align-items: center !important;
    }

    .contact-list li {
        justify-content: center !important;
        flex-direction: column !important;
        gap: 0.35rem !important;
        text-align: center !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    /* Target the UL specifically to control item spacing */
    .footer-col .contact-list {
        gap: 1.5rem !important;
    }

    .contact-list li i {
        margin-top: 0 !important;
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
    }

    .newsletter-section {
        margin-top: 1rem !important;
        padding: 0 1rem !important;
    }

    .footer-bottom {
        padding-top: 1.5rem !important;
        padding-bottom: 5rem !important;
        margin-top: 1rem !important;
    }

    .footer-bottom p {
        font-size: 0.85rem !important;
    }
}