/* STYLE GUIDE FOR AI MODIFICATIONS
 * 1. Mobile-first: Base styles mobile, then desktop in media queries
 * 2. Naming convention: .block__element--modifier
 * 3. Color system: Using CSS variables for consistency
 * 4. Typography: Use rem units based on 16px root
 * 5. Focus on clean, usable mobile interface
 */

:root {
  --color-primary: #0066cc;
  --color-primary-rgb: 0, 102, 204; /* Added RGB version of primary color */
  --color-secondary: #3182ce;
  --color-accent: #ffc107;
  --color-dark: #2d3748;
  --color-light: #f8f9fa;
  --color-gray: #718096;
  --color-border: #e2e8f0;
  --color-success: #2ecc71;
  --color-danger: #e74c3c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* New color variables */
  --color-bg-header: #f2f7fd; /* Light blue-gray background for header */
  --color-bg-body: #f7f9fc; /* Very light blue-gray for page background */
  --color-bg-card: #ffffff; /* Keep cards white for contrast */
}

/* Mobile-specific styles - Only apply these on small screens */
@media (max-width: 767.98px) {
  html {
      height: 100%;
      box-sizing: border-box;
      /* overflow: hidden !important; /* Consider removing or testing without this */
  }
  body {
    height: 100%; /* Make body fill html */
    overflow: hidden; /* Prevent body itself from scrolling; scrolling is handled by app-container */
    box-sizing: border-box; 
    padding-bottom: 0 !important; 
    margin: 0 !important; /* Ensure no default margin */
    background-color: var(--color-bg-body) !important; 
    display: flex !important; 
    flex-direction: column !important; 
  }

  /* NEW: Style the main mobile wrapper */
  .d-block.d-md-none {
      /* height: 100dvh !important; /* Let it fill the body via flex */
      flex: 1; /* Make this container take all available space in the body flex container */
      display: flex !important; 
      flex-direction: column !important; 
      overflow: hidden !important; /* This is okay to clip its children if they misbehave, but app-container handles its own scroll */
      box-sizing: border-box; 
  }
  
  /* Hide desktop navigation */
  .navbar.fixed-top,
  .navbar.navbar-expand-lg {
    display: none !important;
  }
  
  /* Keep Enhanced support section styles as they are used in the new header */
  .mobile-header__support {
    display: flex;
    align-items: center;
    text-decoration: none;
    background-color: rgba(30, 30, 47, 0.07);
    padding: 0.4rem 0.6rem;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  }
  
  .mobile-header__support:active {
    background-color: rgba(var(--color-primary-rgb), 0.12);
    transform: translateY(1px);
  }
  
  .mobile-header__call-icon {
    width: 32px;
    height: 32px;
    background-color: rgba(var(--color-primary-rgb), 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px; /* Adjusted margin */
    font-size: 18px;
    color: #1e1e2f;
  }
  
  .mobile-header__call-icon i {
    color: #1e1e2f;
    font-size: 1.1rem;
  }
  
  .mobile-header__call-details {
    display: flex;
    flex-direction: column;
  }
  
  .mobile-header__call-title {
    font-size: 12px;
    color: #1e1e2f;
    margin: 0;
    line-height: 1.1;
    font-weight: bold;
  }
  
  .mobile-header__call-number {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin: 0;
    line-height: 1.3;
  }
  
  /* Keep breadcrumb container styles */
  .modern-breadcrumb-container {
    position: fixed;
    /* top is set dynamically in breadcrumb.css based on body class */
    left: 0;
    right: 0;
    z-index: 1030;
    background-color: var(--color-bg-header);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    padding: 0.5rem 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  }
  
  .modern-breadcrumb {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0;
    margin: 0;
    white-space: nowrap;
  }
  
  .modern-breadcrumb::-webkit-scrollbar {
    display: none;
  }
  
  .breadcrumb-back-button {
    margin-right: 0.5rem;
    padding: 0.25rem 0.5rem;
    background-color: white;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    color: var(--color-dark);
    text-decoration: none;
    font-size: 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }
  
  /* Keep search results styling */
  .search-results {
    top: calc(100% + 5px);
    z-index: 1050;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
    background-color: white;
    position: absolute; /* Ensure it's positioned correctly relative to search input */
    left: 0;
    right: 0;
    /* Added styles for height limit and scroll */
    max-height: 280px; /* Limit height (adjust as needed, e.g., 250px-300px) */
    overflow-y: auto; /* Enable vertical scroll if content exceeds max-height */
    /* --- */
  }
  
  /* Keep WhatsApp float hide rule for product detail */
  .product-detail-container .whatsapp-float {
    display: none !important;
  }
  
  /* Keep desktop element overrides */
  .d-md-none .shop-hero, 
  .d-md-none .filter-sidebar,
  .d-md-none .product-controls:not(.mobile-controls) {
    display: none !important;
  }

  /* --- Styles for the NEW Mobile Structure --- */
  .app-container {
    width: 100%;
    background: var(--color-bg-body); /* Use variable */
    padding-top: 10px; /* Reset padding-top, add small buffer */
    padding-left: 10px; /* Slightly reduced side padding */
    padding-right: 10px; /* Slightly reduced side padding */
    padding-bottom: 10px; /* Add small buffer at bottom */
    position: relative; /* Keep for absolutely positioned children like buttons */

    /* Ensure app-container scrolls and takes remaining space */
    flex: 1 1 auto; /* Allow app-container to grow and shrink, taking available space */
    overflow-y: auto !important; /* Crucial for scrolling */
    -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
    min-height: 0; /* Important for flex children to allow shrinking before scrolling */
    box-sizing: border-box; /* DEBUG */
  }

  /* REMOVED: Specific padding-top rules for category/product pages */
  /* .category-detail-page .app-container, ... */

  /* Styles for .sticky-controls header */
  .sticky-controls {
    /* REMOVED: position: sticky; */
    /* REMOVED: top: 0; */
    background: var(--color-bg-header); /* Use variable */
    z-index: 10; /* Keep z-index for potential overlaps if needed */
    padding: 8px 10px; /* Reduced padding */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* NEW: Prevent shrinking */
    flex-shrink: 0 !important; /* DEBUG */
    box-sizing: border-box; /* DEBUG */
  }

  .header { /* Style for the header div inside sticky-controls */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px; /* Reduced margin */
    /* Removed padding-top, handled by sticky-controls padding */
  }

  .header h1, .header h2 { /* Target h1/h2 within the header */
    font-family: 'Segoe UI', sans-serif;
    font-size: 18px; /* Reduced font size */
    color: #1e1e2f;
    font-weight: bold;
    margin: 0;
    line-height: 1.1;
  }

  .sub-text {
    font-size: 11px; /* Reduced font size */
    color: var(--color-gray);
    margin-bottom: 0;
  }

  /* Styles for .search-bar inside sticky-controls */
  .search-bar {
    display: flex;
    gap: 8px; /* Reduced gap */
    /* Removed margin-bottom, handled by sticky-controls padding */
    width: 100%;
  }

  .search-bar input,
  .search-bar .search-input { /* Target input within search-bar */
    flex: 1;
    padding: 8px 12px; /* Reduced padding */
    border: none;
    border-radius: 10px; /* Smaller radius */
    background: #efefef;
    font-size: 13px; /* Reduced font size */
    height: 36px; /* Reduced height */
  }

  .search-bar button {
    background: #1e1e2f;
    border: none;
    border-radius: 10px; /* Smaller radius */
    padding: 0 12px; /* Reduced padding */
    color: white;
    font-size: 14px; /* Reduced icon size */
    cursor: pointer;
    width: 36px; /* Reduced width */
    height: 36px; /* Reduced height */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Styles for .tabs inside sticky-controls */
  .tabs {
    display: flex;
    gap: 8px; /* Reduced gap */
    margin-top: 8px; /* Reduced margin */
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 3px; /* Reduced padding */
  }

  .tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
  }

  .tabs button {
    padding: 6px 10px; /* Reduced padding */
    border-radius: 15px; /* Smaller radius */
    border: none;
    font-size: 13px; /* Reduced font size */
    background: #efefef;
    color: #333;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
  }

  .tabs button.active {
    background: #1e1e2f;
    color: white;
  }

  /* Styles for .cards container */
  .cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px; /* Reduced gap */
    /* Removed margin-bottom, handled by app-container padding */
  }

  /* Styles for individual .card */
  .card {
    background: white;
    border-radius: 10px; /* Smaller radius */
    padding: 8px; /* Reduced padding */
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  .card:active { /* Add active state */
      transform: scale(0.98);
      box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  }

  .product-card-link { /* Link wrapping card content */
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1; /* Make link fill the card */
  }

  .card img {
    width: 100%;
    height: 100px; /* Reduced height */
    object-fit: contain;
    margin-bottom: 8px; /* Reduced margin */
    /* Removed position: relative; - Add to wrapper instead */
  }

  /* NEW: Wrapper for image to position badge */
  .mobile-card-image-wrapper {
    position: relative;
    width: 100%;
    height: 100px; /* Match image height */
    margin-bottom: 8px; /* Match image margin */
  }

  /* NEW: Mobile Out of Stock Badge */
  .mobile-out-of-stock-badge {
    position: absolute;
    top: 4px; /* Adjust position */
    left: 4px; /* Adjust position */
    background-color: rgba(220, 53, 69, 0.85); /* Danger color with some transparency */
    color: white;
    padding: 2px 5px; /* Adjust padding */
    font-size: 9px; /* Smaller font */
    font-weight: 600;
    border-radius: var(--radius-sm);
    z-index: 2; /* Ensure it's above image */
    line-height: 1.2;
  }

  .card h4 {
    font-size: 13px; /* Reduced font size */
    margin-bottom: 3px; /* Reduced margin */
    color: #111;
    min-height: 38px; /* Ensure consistent height */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
  }

  .card p { /* Brand name */
    font-size: 11px; /* Reduced font size */
    color: #666;
    margin-bottom: 4px; /* Reduced margin */
  }

  .price { /* Price container */
    margin-top: auto; /* Push to bottom */
    font-size: 13px; /* Reduced font size */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 0; /* Reduced padding */
    min-height: 30px; /* Reduced min-height */
  }

  .current-price {
    color: #1e1e2f;
    font-weight: bold;
  }

  .original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 11px; /* Reduced font size */
    margin-left: 5px;
  }
  
  .staff-price-info { /* Style for staff-only price hint */
      font-weight: normal;
  }

  /* Styles for .nav (Bottom Navigation) */
  .nav {
    display: flex !important; 
    justify-content: space-around; 
    align-items: center;
    padding: 5px 0; 
    background: #fff;
    width: 100% !important; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100 !important; 
    height: 60px !important; 
    border-top: 1px solid rgba(0,0,0,0.03);
    flex-shrink: 0 !important; /* Prevent shrinking */
    box-sizing: border-box; 
  }

  .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center content vertically */
    color: #777;
    font-size: 10px; /* Reduced font size */
    text-decoration: none;
    padding: 0 5px;
    flex: 1;
    height: 100%; /* Fill height */
    position: relative; /* For badge positioning */
    transition: color 0.2s ease;
  }

  .nav-item.active {
    color: #1e1e2f;
    font-weight: bold;
  }

  .nav-item i {
    font-size: 20px;
    margin-bottom: 4px;
  }
  
  .nav-item span { /* Text label */
      line-height: 1;
  }
  
  /* Cart badge specific to .nav-item */
  .nav-item .cart-badge {
      position: absolute;
      top: 1px; /* Adjusted position */
      right: 4px; /* Adjusted position */
      background-color: var(--color-danger);
      color: white;
      border-radius: 50%;
      min-width: 15px; /* Slightly smaller */
      height: 15px; /* Slightly smaller */
      font-size: 9px; /* Slightly smaller */
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1px;
      line-height: 1;
  }

  /* Styles for .actions container within .card */
  .actions {
    display: flex;
    flex-direction: column !important; /* Ensure vertical layout */
    gap: 4px; /* Reduced gap */
    margin-top: 6px; /* Reduced margin */
  }

  .actions button, .actions a { /* Target buttons/links within .actions */
    width: 100%;
    border: none;
    border-radius: 6px; /* Smaller radius */
    padding: 6px 8px; /* Reduced padding */
    font-size: 12px; /* Reduced font size */
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex; /* Changed to inline-flex for icon alignment */
    align-items: center; /* Align icon and text vertically */
    justify-content: center; /* Center content */
    font-weight: 500; /* Added weight */
  }

  /* Styling for button feedback states in mobile */
  .actions button .spinner-border-sm {
      margin-right: 0.4em;
      vertical-align: -0.125em;
  }

  .actions button i.bi {
      margin-right: 0.3em;
      vertical-align: -0.1em; /* Adjust as needed */
  }

  .btn-cart { /* Add to Cart / Add to Quote button */
    background-color: #1e1e2f;
    color: white;
  }
  .btn-cart:hover { background-color: #333; }

  .btn-view { /* Quick View button */
    background-color: #efefef;
    color: #1e1e2f;
  }
  .btn-view:hover { background-color: #ddd; }
  
  /* Specific style for Request Quote button if needed */
  .request-quote-btn {
      /* background-color: var(--color-success); */ /* Example: Green quote button */
      /* color: white; */
  }
  /* .request-quote-btn:hover { background-color: #218838; } */

  /* Keep WhatsApp Float */
  .whatsapp-float {
    position: fixed; /* Changed from absolute */
    bottom: 75px; /* Position above the 60px nav + 15px margin */
    right: 15px; /* Adjusted position */
    background-color: #25D366;
    color: white;
    width: 45px; /* Slightly smaller */
    height: 45px; /* Slightly smaller */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px; /* Slightly smaller */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000; /* Ensure it's above cards */
    animation: pulse 2s infinite;
    text-decoration: none; /* Ensure link style is removed */
  }

  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
  }

  /* Keep Scroll Top Button */
  .scroll-top-btn {
    position: fixed; /* Changed from absolute */
    bottom: 75px; /* Position above the 60px nav + 15px margin */
    left: 15px; /* Adjusted position */
    background-color: #1e1e2f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px; /* Slightly smaller */
    height: 36px; /* Slightly smaller */
    font-size: 14px; /* Slightly smaller */
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease, transform 0.3s ease; /* Added transform */
    opacity: 0; /* Start hidden */
  }

  .scroll-top-btn.show {
    display: flex;
    opacity: 1;
  }
  .scroll-top-btn:active {
      transform: scale(0.95); /* Add active state */
  }

  /* Keep No Products Message */
  .no-products {
    grid-column: 1 / span 2; /* Span across grid */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    color: #6c757d;
    text-align: center;
  }

  .no-products i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }

  /* Keep Footer Hide */
  footer, .footer {
    display: none !important;
  }
}

/* Reset body/html styles for desktop */
@media (min-width: 768px) {
    html, body {
        height: auto !important; /* DEBUG */
        overflow: auto !important; /* Revert to auto for desktop */
        border: none !important; /* DEBUG */
    }
    body {
        display: block !important; /* DEBUG */
        border: none !important; /* DEBUG */
        margin: initial; /* Revert body margin for desktop */
    }
    /* Reset mobile wrapper styles */
    .d-block.d-md-none {
        height: auto !important; /* DEBUG */
        flex: none !important; /* DEBUG */
        overflow: visible !important; /* DEBUG */
        border: none !important; /* DEBUG */
    }
    .app-container {
        padding-top: 0 !important; /* Reset mobile padding */
        padding-bottom: 0 !important;
        flex: none; /* Revert flex */
        overflow-y: visible; /* Revert overflow */
        min-height: auto; /* Reset min-height */
        border: none !important; /* DEBUG */
        background-color: transparent !important; /* DEBUG */
    }
    .sticky-controls {
        /* Styles here only apply > 768px if needed, but it's hidden anyway */
        border: none !important; /* DEBUG */
        background-color: transparent !important; /* DEBUG */
    }
    .nav {
        /* Styles here only apply > 768px if needed, but it's hidden anyway */
        border: none !important; /* DEBUG */
        background-color: transparent !important; /* DEBUG */
    }
    .whatsapp-float, .scroll-top-btn {
        position: fixed; /* Revert to fixed for desktop if they were visible */
        /* Adjust bottom/right/left as needed for desktop */
    }
}


