/* Optimized responsive.css - Minimal header bulk on all devices */

/* Variable for viewport height calculation */
:root {
    --vh: 1vh;
    --vw: 1vw; /* Viewport width unit for calculations */
    --mobilePadding: 12px;
    --touchMinSize: 44px;
}

/* Add global overflow control to prevent horizontal scrolling */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Device-specific adjustments */
.mobile-device {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* When menu is open, prevent body scrolling */
.menu-open {
    overflow: hidden;
}

/* iOS specific fixes */
.ios-device {
    -webkit-overflow-scrolling: touch;
}

.ios-device .navbar-collapse {
    /* Fixed position elements need more care on iOS */
    position: absolute;
    transform: translateY(0) translateZ(0);
    -webkit-transform: translateY(0) translateZ(0);
    -moz-transform: translateY(0) translateZ(0);
    -ms-transform: translateY(0) translateZ(0);
    -o-transform: translateY(0) translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
}

.ios-device input,
.ios-device select,
.ios-device button {
    /* Fix for iOS input zooming issues */
    font-size: 16px;
}

/* Touch device specific styles */
.touch-device .navbar-toggler {
    padding: 12px 15px; /* Larger touch target for touch devices */
}

.touch-device .navbar-nav .nav-link {
    padding: 16px 0; /* Larger touch target */
    min-height: 44px; /* Minimum touch target size */
}

.touch-device .dropdown-item {
    padding: 14px 15px; /* Larger touch target */
    min-height: 44px; /* Minimum touch target size */
}

.touch-device .dropdown-toggle::after {
    display: none; /* Hide default arrow */
}

.dropdown-toggle-arrow {
    display: inline-block;
    margin-left: 5px;
    transition: transform 0.3s ease;
    -webkit-transition: transform 0.3s ease;
    -moz-transition: transform 0.3s ease;
    -ms-transition: transform 0.3s ease;
    -o-transition: transform 0.3s ease;
}

.dropdown.show .dropdown-toggle-arrow {
    transform: rotate(180deg);
    -webkit-transform: rotate(180deg);
    -moz-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    -o-transform: rotate(180deg);
}

/* Force hardware acceleration for smoother animations */
.touch-device .navbar-collapse {
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
}

/* Header responsive fixes - HEAVILY OPTIMIZED FOR MINIMAL SPACE */
.site-header .header-top {
    min-height: 40px; /* Reduced for mobile */
}

.site-header .header-top .row {
    align-items: center;
}

/* Mobile header optimization - EXTREME SPACE SAVING */
@media (max-width: 767.98px) {
    /* Reduce header height dramatically */
    .site-header .header-top {
        padding: 5px 0; /* Minimal padding */
        min-height: 40px; /* Very compact */
    }
    
    /* Better column layout to save vertical space */
    .site-header .header-top .col-4,
    .site-header .header-top .col-5,
    .site-header .header-top .col-3,
    .site-header .header-top .col-md-3,
    .site-header .header-top .col-md-6 {
        padding: 0 3px; /* Minimal horizontal padding */
    }
    
    /* Keep everything on one row */
    .header-top .col-5 {
        margin-top: 0; /* No margin - everything on same line */
    }
    
    /* Compact logo */
    .logo img {
        max-height: 30px; /* Smaller mobile logo */
    }
    
    /* Optimized search form with better touch targets */
    .search-form .form-control {
        height: 40px; /* Larger for better touch targets (44px with borders) */
        font-size: 14px; /* Larger text for better readability */
        padding: 5px 12px; /* More comfortable padding */
        border-radius: 4px 0 0 4px; /* Proper radius for left side */
    }
    
    .search-form .btn {
        height: 40px; /* Match input height */
        padding: 5px 12px; /* More comfortable padding */
        font-size: 14px; /* Larger icon size */
        border-radius: 0 4px 4px 0; /* Proper radius for right side */
        min-width: 44px; /* Minimum touch target size */
    }
    
    /* Smaller cart icon */
    .cart-icon {
        font-size: 18px; /* Smaller mobile cart */
    }
    
    .cart-count {
        width: 16px; /* Smaller badge */
        height: 16px;
        font-size: 10px; /* Smaller font */
        top: -6px; /* Adjusted positioning */
        right: -6px;
    }
    
    /* Mobile navigation optimization */
    .navbar-collapse {
        position: fixed;
        top: 80px; /* Standardized position for all screen sizes */
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%; /* Ensure proper width */
        max-width: 100%; /* Prevent overflow */
        max-height: calc(var(--vh, 1vh) * 100 - 80px); /* Using CSS variable for better iOS support */
        overflow-y: auto;
        overflow-x: hidden; /* Prevent horizontal scroll */
        -webkit-overflow-scrolling: touch; /* Better iOS scrolling */
        background-color: #343a40;
        z-index: 9000; /* Standardized z-index hierarchy */
        padding: 10px 15px; /* Slightly increased padding for better touch */
        box-shadow: 0 3px 8px rgba(0,0,0,0.15);
        transition: all 0.3s ease-in-out;
        -webkit-transition: all 0.3s ease-in-out;
        -moz-transition: all 0.3s ease-in-out;
        -ms-transition: all 0.3s ease-in-out;
        -o-transition: all 0.3s ease-in-out;
        opacity: 0;
        transform: translateY(-10px);
        -webkit-transform: translateY(-10px);
        -moz-transform: translateY(-10px);
        -ms-transform: translateY(-10px);
        -o-transform: translateY(-10px);
        border-top: 1px solid #555;
        border-top: 1px solid rgba(255,255,255,0.1); /* Visual separator */
        box-sizing: border-box; /* Ensure padding doesn't add to width */
    }
    
    .navbar-collapse.show {
        opacity: 1;
        transform: translateY(0);
        -webkit-transform: translateY(0);
        -moz-transform: translateY(0);
        -ms-transform: translateY(0);
        -o-transform: translateY(0);
    }
    
    .navbar-dark .navbar-nav .nav-link {
        padding: 12px 0; /* Increased for better touch targets */
        font-size: 14px; /* Slightly larger for better readability */
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .navbar-toggler {
        border-color: rgba(255,255,255,0.3);
        padding: 12px 15px; /* Much larger touch target (44px minimum) */
        font-size: 16px; /* Slightly larger for better visibility */
        margin-right: 0;
        position: relative;
        z-index: 9100; /* Standardized z-index hierarchy */
        min-width: 44px; /* Minimum touch target size */
        min-height: 44px; /* Minimum touch target size */
    }
    
    .navbar-toggler:focus,
    .navbar-toggler:active {
        outline: none !important;
        box-shadow: none !important;
    }
    
    .navbar-toggler-icon {
        width: 24px; /* Larger icon */
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Very small screens - even more compact */
@media (max-width: 575.98px) {
    /* Extra overrides to prevent horizontal scrolling */
    .container {
        width: 100%;
        max-width: 100%;
        padding-left: 8px;
        padding-right: 8px;
        box-sizing: border-box;
    }

    /* Ensure site doesn't overflow */
    .row {
        margin-left: -5px;
        margin-right: -5px;
    }
    
    .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, 
    .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, 
    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, 
    .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
        padding-left: 5px;
        padding-right: 5px;
    }
    .site-header .header-top {
        padding: 3px 0; /* Minimal padding */
        min-height: 35px; /* Extremely compact */
    }
    
    /* Make the layout even more compact */
    .logo img {
        max-height: 25px; /* Even smaller logo */
    }
    
    /* Keep consistent input sizes even on very small screens */
    .search-form .form-control,
    .search-form .btn {
        height: 38px; /* Still large enough for touch targets */
        font-size: 13px; /* Readable text size */
    }
    
    /* Maintain comfortable padding on very small screens */
    .search-form .form-control {
        padding: 5px 10px; /* Comfortable padding */
    }
    
    .cart-icon {
        font-size: 22px; /* Larger cart icon for better touch target */
        padding: 8px; /* Added padding for better touch target */
        display: inline-block;
        min-width: 44px; /* Minimum touch target size */
        min-height: 44px; /* Minimum touch target size */
        text-align: center;
    }
    
    .cart-count {
        width: 20px; /* Larger badge for better visibility */
        height: 20px;
        font-size: 11px; /* Larger font for better readability */
        line-height: 20px;
    }
    
    /* Ensure everything stays on one line */
    .site-header .header-top .col-4,
    .site-header .header-top .col-5,
    .site-header .header-top .col-3 {
        padding: 0 2px; /* Even more minimal padding */
    }
}

/* Global Responsive Adjustments */
@media (max-width: 1199.98px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .slider-content h1 {
        font-size: 42px;
        font-weight: bold;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Navbar */
    .navbar-dark .navbar-nav .nav-link {
        padding: 10px 8px; /* Slightly reduced */
        font-size: 13px;
    }
    
    /* Slider */
    .slider-item {
        height: 450px;
    }
    
    .slider-content h1 {
        font-size: 34px;
        font-weight: bold;
    }
    
    /* Product cards */
    .product-title {
        font-size: 15px;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Header adjustments */
    .site-header .logo img {
        max-height: 35px; /* Smaller than desktop */
    }
    
    .search-form .form-control,
    .search-form .btn {
        height: 30px; /* Compact on tablets */
    }
    
    /* Navbar */
    .navbar-dark .navbar-nav .nav-link {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    /* Slider */
    .slider-item {
        height: 400px;
    }
    
    .slider-content {
        max-width: 60%;
        padding: 15px;
    }
    
    .slider-content h1 {
        font-size: 30px;
        margin-bottom: 15px;
        font-weight: bold;
    }
    
    .slider-content p {
        font-size: 16px;
        margin-bottom: 20px;
    }
    
    /* Product cards */
    .product-image img {
        height: 200px;
    }
    
    .product-title {
        font-size: 14px;
        height: 36px;
    }
    
    .product-actions .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* Cart & Checkout */
    .cart-summary, 
    .order-summary {
        position: static;
        margin-top: 30px;
    }
    
    /* Footer */
    .site-footer h5 {
        font-size: 18px;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    /* Compact headers */
    .header-top {
        padding: 8px 0;
    }
    
    .site-header .logo img {
        max-height: 32px;
    }
    
    .search-form {
        margin: 8px 0; /* Reduced margin */
    }
    
    /* Navbar */
    .navbar-collapse {
        background-color: #212529;
        padding: 10px;
        z-index: 1000;
        box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    }
    
    .navbar-dark .navbar-nav .nav-link {
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 10px 0;
    }
    
    .navbar-dark .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    
    .dropdown-menu {
        background-color: rgba(0,0,0,0.2);
        border: none;
        padding: 0 0 0 15px;
        margin-top: 0;
        box-shadow: none;
    }
    
    .dropdown-item {
        color: #f8f9fa;
        padding: 6px 10px; /* Reduced padding */
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    
    .dropdown-item:hover {
        background-color: transparent;
        color: #007bff;
    }
    
    /* Slider */
    .slider-item {
        height: 300px;
    }
    
    .slider-content {
        max-width: 85%;
        padding: 20px;
    }
    
    .slider-content h1 {
        font-size: 24px;
        margin-bottom: 10px;
        font-weight: bold;
    }
    
    .slider-content p {
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    /* Categories */
    .category-card .card-img-top {
        height: 150px;
    }
    
    /* Product cards */
    .product-image img {
        height: 180px;
    }
    
    .product-title {
        font-size: 14px;
        height: 35px;
    }
    
    .product-price .price {
        font-size: 16px;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .product-actions .btn {
        margin: 3px 0;
        width: 100%;
    }
    
    /* Product detail */
    .product-detail .product-title {
        font-size: 22px;
    }
    
    .product-detail .product-price .price {
        font-size: 20px;
    }
    
    /* Cart & Checkout */
    .cart-items {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        width: 100%;
    }
    
    .cart-items .table {
        font-size: 13px;
        width: 100%;
    }
    
    .qty-input {
        width: 40px;
    }
    
    /* Footer */
    .site-footer .col-md-3,
    .site-footer .col-md-4,
    .site-footer .col-md-2 {
        margin-bottom: 30px;
    }
}

/* Extra Small Devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    /* Headers - Keep horizontal layout for mobile */
    .header-top .row {
        flex-direction: row; /* Keep horizontal layout */
        align-items: center;
    }
    
    .header-top .col-4,
    .header-top .col-5,
    .header-top .col-3,
    .header-top .col-md-3,
    .header-top .col-md-6 {
        padding: 0 2px; /* Minimal padding */
    }
    
    /* Navbar */
    .navbar-toggler {
        margin-left: auto;
        margin-right: 0;
        display: block;
        padding: 6px 8px;
    }
    
    /* Ensure consistent navbar-collapse across breakpoints */
    .navbar-collapse {
        background-color: #212529;
        padding: 10px 15px; /* Consistent padding */
        z-index: 9000; /* Consistent z-index */
        box-shadow: 0 6px 12px rgba(0,0,0,0.15);
        top: 70px; /* Adjust for smaller header height on very small screens */
        max-height: calc(var(--vh, 1vh) * 100 - 70px); /* Using CSS variable for better iOS support */
        -webkit-overflow-scrolling: touch; /* Better iOS scrolling */
    }
    
    .navbar-dark .navbar-nav .nav-link {
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 10px 0; /* Slightly larger touch target */
        font-size: 14px; /* Better readability */
    }
    
    .navbar-dark .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    
    .dropdown-menu {
        background-color: rgba(0,0,0,0.2);
        border: none;
        padding: 0 0 0 15px;
        margin-top: 0;
        box-shadow: none;
        position: static !important;
        float: none;
        width: 100%;
        display: none;
    }
    
    .dropdown-item {
        color: #f8f9fa;
        padding: 10px 10px; /* Increased touch target */
        border-bottom: 1px solid rgba(255,255,255,0.05);
        white-space: normal; /* Allow text wrapping */
    }
    
    .dropdown-item:hover,
    .dropdown-item:active,
    .dropdown-item:focus {
        background-color: rgba(0,123,255,0.1);
        color: #007bff;
    }
    
    /* Titles */
    .section-title h2 {
        font-size: 24px;
    }
    
    /* Slider */
    .slider-item {
        height: 250px;
    }
    
    .slider-content {
        max-width: 90%;
        padding: 15px;
    }
    
    .slider-content h1 {
        font-size: 20px;
        margin-bottom: 10px;
        font-weight: bold;
    }
    
    .slider-content p {
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .slider-content .btn {
        padding: 6px 15px;
        font-size: 12px;
        margin-bottom: 5px;
        display: block;
        width: 100%;
    }
    
    /* Categories */
    .category-card .card-img-top {
        height: 120px;
    }
    
    .category-card .card-title {
        font-size: 14px;
    }
    
    /* Product cards */
    .product-image img {
        height: 150px;
    }
    
    .product-details {
        padding: 10px;
    }
    
    .product-title {
        font-size: 12px;
        height: 32px;
        overflow: hidden;
        margin-bottom: 5px;
    }
    
    .product-price .price {
        font-size: 14px;
    }
    
    .product-price .regular-price {
        font-size: 12px;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .product-actions .btn {
        margin: 3px 0;
        width: 100%;
        font-size: 10px;
        padding: 5px 8px;
    }
    
    /* Product detail */
    .product-detail .product-title {
        font-size: 18px;
    }
    
    .product-detail .product-price .price {
        font-size: 18px;
    }
    
    .product-detail .product-price .regular-price {
        font-size: 14px;
    }
    
    /* Cart & Checkout - Improved for mobile scrolling */
    .cart-items {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        width: 100%;
    }
    
    .cart-items .table {
        font-size: 12px;
        /* Removed min-width that was causing overflow */
        width: 100%;
    }
    
    .cart-items .table img {
        width: 50px;
        height: 50px;
    }
    
    .qty-input {
        width: 40px;
    }
    
    .checkout-form .card-header h5 {
        font-size: 16px;
    }
    
    /* Newsletter */
    .newsletter-section h3 {
        font-size: 20px;
    }
    
    .newsletter-form .btn {
        width: 100%;
        margin-top: 10px;
    }
    
    .newsletter-form .input-group {
        flex-direction: column;
    }
    
    .newsletter-form .form-control {
        border-right: 1px solid #ced4da;
        border-radius: 4px;
    }
    
    /* Footer */
    .site-footer h5 {
        font-size: 18px;
        margin-top: 10px;
    }
    
    .site-footer .col-md-3,
    .site-footer .col-md-4,
    .site-footer .col-md-2 {
        margin-bottom: 20px;
    }
    
    .social-link {
        width: 35px;
        height: 35px;
    }
    
    .site-footer .row:last-child {
        text-align: center;
    }
    
    .site-footer .text-right {
        text-align: center !important;
        margin-top: 10px;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    width: 50px; /* Larger for better touch target */
    height: 50px; /* Larger for better touch target */
    line-height: 50px;
    text-align: center;
    background-color: #007bff;
    color: #fff;
    border-radius: 50%;
    z-index: 8000; /* Standardized z-index hierarchy */
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

.back-to-top:hover {
    background-color: #0069d9;
}

@media (max-width: 767.98px) {
    .back-to-top {
        width: 44px; /* Minimum touch target size */
        height: 44px; /* Minimum touch target size */
        line-height: 44px;
        bottom: 15px;
        right: 15px;
    }
}

/* Search page mobile adjustments */
@media (max-width: 575.98px) {
    .search-header {
        padding: 15px 0;
    }
    
    .search-header h1 {
        font-size: 18px;
    }
    
    .search-header .text-muted {
        font-size: 12px;
    }
    
    .search-results .product-card {
        margin-bottom: 20px;
    }
}