/* =========================================
   1. GLOBAL STYLES 
   ========================================= */
body { 
    font-family: Arial, sans-serif; 
    background-color: #f9f9f9; 
    margin: 0; 
    padding-bottom: 80px; /* Space for bottom nav */
    /* Fix for mobile horizontal scroll */
    overflow-x: hidden; 
}

.search-form {
    width: 100%;
}

/* --- CLEAN & FIXED BOTTOM NAVIGATION --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px; 
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #eee;
    z-index: 999; 
    overflow: hidden; 
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%; 
    text-decoration: none;
    transition: background 0.2s ease;
}

.info-container {
    padding-bottom: 100px !important; 
}

/* Icons sizing preserved exactly */
.bottom-nav img, 
.nav-item img {
    width: 32px !important;   
    height: 32px !important; 
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
}

.nav-item.active {
    box-shadow: inset 0 -4px 0 0 black;
    background: rgba(0, 0, 0, 0.02); 
}

.nav-item.active img {
    filter: brightness(0);
}

/* =========================================
   3. ORDERING MODULE (HOME GRID)
   ========================================= */

.back-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.3s;
}

.back-nav a:hover {
    color: #666;
    transform: translateX(-5px); 
}

.product-grid {
    display: grid;
    /* UPDATED: Dynamic grid that fits more items on larger screens */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 15px;
    padding: 15px;
}

.product-card {
    background: white;
    border-radius: 12px; /* Smoother corners */
    padding: 12px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover { transform: translateY(-3px); }

.product-card img {
    width: 100%;
    aspect-ratio: 1 / 1; /* Keeps images square and uniform */
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* Rating Stars Styling */
.product-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 4px 0;
}

.star {
    color: #f1c40f; 
    font-size: 12px;
}

.rating-count {
    font-size: 11px;
    color: #888;
    margin-left: 5px;
}

/* =========================================
   4. PRODUCT DETAIL & FORM ELEMENTS
   ========================================= */
.product-detail-container { padding: 20px; max-width: 800px; margin: auto; }

.select-style {
    width: 100%; /* Default to full width for mobile */
    max-width: 300px; /* Keep it controlled on desktop */
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    margin: 10px 0;
}

.btn-primary,
.btn-secondary { 
    background: #333; 
    color: white; 
    border: none; 
    padding: 12px 25px; 
    border-radius: 20px; 
    cursor: pointer;
    width: 100%; /* Full width for mobile */
    max-width: 300px; 
    margin-top: 20px;
    font-weight: bold;
}

/* =========================================
   5. ADMIN & INVENTORY
   ========================================= */
.admin-tabs {
    display: flex;
    justify-content: center;
    border-bottom: 1px solid #ddd;
    background: white;
    padding: 10px 0;
    position: sticky;
    top: 50px; /* Sits below search header */
    z-index: 100;
}

.admin-tabs a {
    margin: 0 10px;
    font-size: 13px;
    text-decoration: none;
    color: #666;
    font-weight: bold;
}

.admin-tabs a.active { color: black; border-bottom: 2px solid black; }

/* =========================================
   7. TOP TABS
   ========================================= */
.top-tab-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
    background: #ffffff;
    border-bottom: 1px solid #eeeeee;
    width: 100%;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    opacity: 0.5;
    text-align: center;
    flex: 1;
    text-decoration: none;
    color: #333333;
}

.tab-item.active {
    opacity: 1;
    box-shadow: inset 0 -2px 0 0 black;
}

/* =========================================
   9. SEARCH HEADER (RESPONSIVE)
   ========================================= */
.search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 60px; /* Slightly taller for better touch targets */
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Specific fix for the search bar icon */
.small-search-icon {
    width: 5px !important;   /* Professional small size */
    height: 5px !important;
    opacity: 0.5;             /* Subtle look to match placeholder text */
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Ensure the button doesn't add extra padding */
.search-action-btn {
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Align the wrapper inside the search bar */
.search-action-wrapper {
    display: flex;
    align-items: center;
    padding-left: 8px;
    height: 10;
}

.header-logo {
    height: 35px; /* Scaled for mobile header */
    width: auto;
}

.search-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f1f1f1;
    border-radius: 10px;
    height: 40px;
    padding: 0 10px;
}

/* =========================================
   10. MOBILE MEDIA QUERIES (THE CORE FIX)
   ========================================= */

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* Exactly 2 items per row on phones */
        gap: 10px;
        padding: 10px;
    }

    .product-card {
        padding: 10px;
    }

    .product-card h4 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn-primary, .btn-secondary, .select-style {
        width: 100% !important;
        max-width: none;
    }

    .search-header {
        height: 55px;
    }

    /* Success Toast adjustment for mobile */
    .success-toast {
        width: 80%;
        font-size: 13px;
        padding: 10px 15px;
    }
}

/* Very small screens (iPhone SE, etc) */
@media (max-width: 380px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .product-card h4 { font-size: 12px; }
}