/*
 Theme Name:   Minimalist Mobile Ordering Child Theme
 Description:  Clean, highly aligned mobile interface optimized for POS order building.
 Template:     storefront
*/

/* ==========================================================================
   1. CSS Variables & Base Reset
   ========================================================================== */
:root {
  --bg-color: #ffffff;
  --text-primary: #000000;
  --text-secondary: #555555;
  --border-color: #000000;
  --border-light: #e0e0e0;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. Header & Search Bar (Updated for Squish Fix)
   ========================================================================== */
.site-header {
  border-bottom: 3px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-color);
  z-index: 100;
  /* Override fixes below */
  min-height: 65px !important; 
  padding: 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.site-logo {
  flex: 0 0 120px;
  border-right: 3px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  text-transform: uppercase;
}

.site-logo img, 
.custom-logo-link img {
  max-height: 80px !important;
  width: auto !important;
  margin: 0 !important;
}

.header-search-container {
  flex-grow: 1;
  padding: var(--spacing-sm) var(--spacing-md);
}

.product-search-bar {
  display: flex;
  align-items: center;
  width: 100%;
  flex-grow: 1;
  margin-left: 15px;
}

.product-search-bar input[type="search"],
.product-search-bar input[type="text"] {
  border: 1px solid var(--border-color);
  outline: none;
  width: 100%;
  min-height: 35px;
  padding: 5px 10px;
  font-size: 16px;
  background: transparent;
}

/* ==========================================================================
   3. Filter Section & Drawer
   ========================================================================== */
.filter-toggle-container {
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.filter-toggle-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.filter-drawer {
  position: fixed;
  top: 0;
  left: -100%;
  width: 80%;
  max-width: 300px;
  height: 100vh;
  background: var(--bg-color);
  border-right: 2px solid var(--border-color);
  z-index: 1000;
  transition: left 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.filter-drawer.open {
  left: 0;
}

.filter-drawer-header {
  padding: var(--spacing-md);
  border-bottom: 2px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.close-filter-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.filter-options {
  list-style: none;
  padding: 0;
}

.filter-options li {
  border-bottom: 1px solid var(--border-light);
}

.filter-options a {
  display: block;
  padding: var(--spacing-md);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
}

/* ==========================================================================
   4. Top 20 Best Selling Grid
   ========================================================================== */
.section-title {
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-md);
  font-size: 16px;
  font-weight: normal;
}

.best-sellers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  margin: 0 var(--spacing-md);
}

.grid-product-card {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
}

.grid-product-card .price,
.grid-product-card .star-rating,
.grid-product-card .product-description {
  display: none;
}

/* ==========================================================================
   5. Alphabetical Product List (Restored)
   ========================================================================== */
.alphabetical-list-container {
  margin-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.list-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
  font-size: 16px;
  color: var(--text-secondary);
}

.product-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
}

.product-list-item .product-title {
  font-weight: 500;
}

.product-list-item .add-to-order-btn {
  background: var(--bg-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: bold;
}

/* ==========================================================================
   Aggressive Mobile Grid Realignment & Standardizing (FOR 3 COLUMNS)
   Fixes issues seen in image_8.png to match wireframe.
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Force strict Grid container structure */
  body.woocommerce ul.products, 
  body .woocommerce ul.products,
  body .woocommerce-page ul.products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-gap: 5px !important; /* Standardized small gap */
    margin: 0 !important;
    padding: 0 !important;
    align-items: stretch !important; /* Force internal items to stretch the full cell height */
  }

 /* 2. Standardize the Product Card Cell and internal alignment */
  body.woocommerce ul.products li.product, 
  body .woocommerce ul.products li.product,
  body .woocommerce-page ul.products li.product {
    display: flex !important; 
    flex-direction: column !important; 
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important; 
    margin: 0 !important;
    padding: 5px !important;
    clear: none !important;
    text-align: center;
    border: 1px solid var(--border-light) !important; 
    background: #fff !important;
    height: 100% !important; /* Ensure the card stretches to fill the grid row */
  }

  /* Acts as a spring to push the button to the bottom */
  body.woocommerce ul.products li.product .woocommerce-loop-product__link {
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important; /* Takes up all available empty space */
    align-items: center !important;
  }

  /* 3. Force Uniformly Sized (Square) Images */
  body.woocommerce ul.products li.product img, 
  body .woocommerce ul.products li.product img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important; /* Forces a perfect square */
    object-fit: contain !important; /* Prevents cropping, centers product/placeholder */
    margin-bottom: 5px !important;
  }

  /* 4. Force Uniform Title Height & Standardize Wrapping */
  body.woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: 11px !important;
    line-height: 1.2 !important;
    text-align: center !important;
    padding: 0 4px !important;
    margin-bottom: 5px !important;
    
    /* Strict Uniform Title Height Logic (Clamps to 2 lines maximum) */
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    height: 2.4em !important; /* Fixed height (line-height * 2 lines) ensures uniform alignment */
  }

  /* 5. Standardize Price Display Size */
  body.woocommerce ul.products li.product .price {
    font-size: 12px !important;
    text-align: center !important;
    margin-bottom: 8px !important;
    display: block !important;
  }

  /* 6. Standardize Button Sizes, Fix Wrapping, and Align at Bottom */
  body.woocommerce ul.products li.product .button,
  body.woocommerce ul.products li.product .add_to_cart_button {
    margin-top: auto !important; /* Pushes the button to the absolute bottom */
    width: 100% !important; 
    padding: 5px 2px !important; /* Smaller side padding prevents letter-stacking */
    font-size: 11px !important; 
    line-height: 1.2 !important; 
    text-transform: uppercase !important;
    background: #f0f0f0 !important; 
    color: #000 !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 0 !important; 
    
    /* Fix the "Read more" vertical letter stacking and lock the height */
    word-break: keep-all !important; 
    white-space: normal !important;
    min-height: 44px !important; /* Uniform height for ALL buttons */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* ==========================================================================
   6. Floating Search Button
   ========================================================================== */
.floating-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  background-color: var(--border-color);
  color: var(--bg-color);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.floating-btn.visible {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Hide Pagination ONLY on the Best Sellers Grid
   ========================================================================== */
.hide-top-pagination .woocommerce-pagination {
    display: none !important;
}


