/**
 * Gallery View - Modern Product Grid
 * New gallery-style product listing with color swatches and size hover
 */

/* Hide the gray subcategory buttons - not in mockup design */
#topcat_head {
  display: none !important;
}

/* Modern Filter Bar - matches reference design */
/* Mobile filter styles - visibility controlled by filter-modern.css media queries */
#mobile_filter {
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

#mobile_filter input[type="button"],
#mobile_filter .filter3,
#mobile_filter .filter4 {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0;
  padding: 10px 20px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  width: auto !important;
  min-width: 120px;
}

#mobile_filter input[type="button"]:hover,
#mobile_filter .filter3:hover,
#mobile_filter .filter4:hover {
  border-color: #ccae6a;
  color: #333;
}

#mobile_filter input[type="button"]:focus,
#mobile_filter .filter3:focus,
#mobile_filter .filter4:focus {
  outline: none;
  border-color: #ccae6a;
}

.category_filters {
  display: none !important;
}

/* View Toggle Switch - matches mockup design */
.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  float: right;
  margin: 5px 0;
}

.view-toggle-label {
  font-size: 12px;
  color: #333;
  font-weight: normal;
}

.view-toggle-btn {
  padding: 5px 15px;
  border: 1px solid #999;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  color: #333;
  white-space: nowrap;
  flex: 0 0 auto;
  width: auto;
  min-width: 84px;
  box-sizing: border-box;
  overflow: visible;
  text-align: center;
}

.view-toggle {
  overflow: visible;
}

.view-toggle-btn:first-of-type {
  border-radius: 0;
}

.view-toggle-btn:last-of-type {
  border-radius: 0;
  margin-left: -1px;
}

.view-toggle-btn.active {
  background: #8b0000;
  color: #fff;
  border-color: #8b0000;
  position: relative;
  z-index: 1;
}

.view-toggle-btn:hover:not(.active) {
  background: #f0f0f0;
}

/* Gallery Grid Container - hidden by default, shown via JS when gallery mode is active */
.gallery-grid {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 15px 0;
  width: 100% !important;
  box-sizing: border-box;
  justify-content: space-between;
}

/* When gallery view is active (set by JS) */
.gallery-grid.active {
  display: flex;
}

/* Make sure gallery fills available space in #content */
#content .gallery-grid {
  width: 100% !important;
  clear: both;
  float: left;
}

/* Gallery Product Item - 4 items per row to fit with sidebar */
.gallery-item {
  position: relative;
  width: 23%;
  flex: 0 0 23%;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.3s, transform 0.2s;
  box-sizing: border-box;
  margin-bottom: 10px;
}

.gallery-item:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transform: translateY(-3px);
  border-color: #ccae6a;
}

/* Product Image Container */
.gallery-item-image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 280px;
  overflow: hidden;
  background: #f9f9f9;
  text-align: center;
}

.gallery-item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: transform 0.3s;
}

.gallery-item:hover .gallery-item-image img {
  transform: none;
}

.gallery-item-image:hover img {
  transform: none;
}

/* Wishlist Heart Icon */
.gallery-item-wishlist {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}

.gallery-item-wishlist:hover {
  background: #fff;
}

.gallery-item-wishlist svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #666;
  stroke-width: 2;
}

.gallery-item-wishlist.active svg {
  fill: #e74c3c;
  stroke: #e74c3c;
}

/* Badge (Topseller, Sale, New) */
.gallery-item-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  border-radius: 2px;
  z-index: 10;
}

.gallery-item-badge.topseller {
  background: #ccae6a;
  color: #fff;
}

.gallery-item-badge.sale {
  background: #e74c3c;
  color: #fff;
}

.gallery-item-badge.new {
  background: #27ae60;
  color: #fff;
}

.gallery-item-badge.sustainable {
  background: #2ecc71;
  color: #fff;
}

.gallery-item-badge.seamless {
  background: #9b59b6;
  color: #fff;
}

.gallery-item-badge.new_color {
  background: #3498db;
  color: #fff;
}

.gallery-item-badge.new_size {
  background: #f39c12;
  color: #fff;
}

/* Product Info Section */
.gallery-item-info {
  padding: 12px 15px 15px;
}

/* Color Swatches */
.gallery-item-colors {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.gallery-color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid #ccc;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-color-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 5;
}

.gallery-color-swatch.active {
  border-color: #333;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px #333;
}

/* Brand Name */
.gallery-item-brand {
  font-size: 12px;
  color: #888;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Product Name */
.gallery-item-name {
  font-size: 14px;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.4;
  height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.gallery-item-name a {
  color: inherit;
  text-decoration: none;
}

.gallery-item-name a:hover {
  color: #ccae6a;
}

/* Price */
.gallery-item-price {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.gallery-item-price .old-price {
  font-size: 13px;
  color: #999;
  text-decoration: line-through;
  font-weight: normal;
  margin-right: 8px;
}

.gallery-item-price .sale-price {
  color: #e74c3c;
}

/* Size Preview */
.gallery-item-sizes {
  display: block;
  background: #fafafa;
  padding: 8px 10px;
  margin-top: 8px;
  border-radius: 4px;
}

.gallery-sizes-list {
  display: block;
  font-size: 10px;
  color: #666;
  line-height: 1.5;
  word-spacing: 1px;
  margin-bottom: 4px;
}

.gallery-sizes-note {
  display: block;
  font-size: 11px;
  color: #28a745;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.gallery-sizes-available {
  display: block;
  font-size: 12px;
  color: #666;
  text-decoration: none;
  font-style: italic;
}

.gallery-sizes-available:hover {
  color: #333;
  text-decoration: underline;
}

.gallery-sizes-more {
  color: #ccae6a;
  font-weight: 600;
}

a.gallery-size-tag,
.gallery-size-tag {
  display: inline;
  padding: 0;
  font-size: 11px;
  background: none;
  border: none;
  color: #666;
  text-decoration: none;
  cursor: pointer;
}

a.gallery-size-tag:hover,
.gallery-size-tag:hover {
  color: #333;
  text-decoration: underline;
}

a.gallery-size-tag::after {
  content: " ";
}

a.gallery-size-more,
.gallery-size-more {
  color: #999;
  font-style: italic;
}

/* Responsive Adjustments */
@media screen and (max-width: 1200px) {
  .gallery-item {
    width: 32%;
    flex: 0 0 32%;
  }
}

@media screen and (max-width: 950px) {
  .gallery-item {
    width: 32%;
    flex: 0 0 32%;
  }
}

@media screen and (max-width: 700px) {
  .gallery-item {
    width: 48%;
    flex: 0 0 48%;
  }
}

@media screen and (max-width: 450px) {
  .gallery-item {
    width: calc(50% - 4px);
    flex: 0 0 calc(50% - 4px);
  }

  .gallery-grid {
    gap: 8px;
  }
}

/* Gallery Grid - default hidden, shown via JS when gallery mode is active */
/* Note: JS will override display to 'flex' when gallery mode is selected */

/* Quick Add to Cart on Hover */
.gallery-item-actions {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  padding: 10px 15px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 12;
}

.gallery-item:hover .gallery-item-actions {
  opacity: 1;
}

.gallery-add-btn {
  width: 100%;
  padding: 10px;
  background: #14294b;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}

.gallery-add-btn:hover {
  background: #1e3a5f;
}

/* 1300px width adjustments - 4 columns with sidebar */
@media screen and (min-width: 1001px) {
  .gallery-grid {
    width: 100% !important;
    gap: 8px !important;
    justify-content: flex-start !important;
  }
  
  .gallery-item {
    width: calc(25% - 6px) !important;
    flex: 0 0 calc(25% - 6px) !important;
    max-width: calc(25% - 6px) !important;
  }
  
  .gallery-item-image {
    height: 320px !important;
  }
}

/* Ensure sizes are clickable */
.gallery-size-tag {
  cursor: pointer;
}

.gallery-size-tag a {
  color: inherit;
  text-decoration: none;
  display: block;
}

/* Mobile Responsive - Gallery View */
@media (max-width: 900px) {
  .gallery-grid {
    gap: 15px !important;
  }
  
  .gallery-item {
    width: calc(33.333% - 12px) !important;
    flex: 0 0 calc(33.333% - 12px) !important;
    max-width: calc(33.333% - 12px) !important;
  }
}

@media (max-width: 650px) {
  .gallery-item {
    width: calc(50% - 10px) !important;
    flex: 0 0 calc(50% - 10px) !important;
    max-width: calc(50% - 10px) !important;
  }

  .gallery-item-image {
    height: 220px;
  }
}

@media (max-width: 450px) {
  .gallery-grid {
    gap: 8px !important;
  }

  .gallery-item {
    width: calc(50% - 4px) !important;
    flex: 0 0 calc(50% - 4px) !important;
    max-width: calc(50% - 4px) !important;
  }

  .gallery-item-image {
    height: 180px;
  }

  .gallery-item-info {
    padding: 8px;
  }

  .gallery-item-brand {
    font-size: 9px;
  }

  .gallery-item-name {
    font-size: 11px;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .gallery-item-price {
    font-size: 13px;
  }

  .gallery-item-colors {
    gap: 4px;
  }

  .gallery-color-swatch {
    width: 14px;
    height: 14px;
  }

  .gallery-item-sizes {
    display: none;
  }
}

/* View toggle mobile - HIDE on mobile, only gallery view */
@media (max-width: 768px) {
  /* Hide view toggle completely on mobile */
  .view-toggle {
    display: none !important;
  }
  
  /* Force gallery view on mobile - hide classic view products ONLY inside #content (category/search pages) */
  /* Wishlist page has no #content wrapper, so products display normally there */
  #content .prod_single,
  #content .prod_single_cross {
    display: none !important;
  }
  
  /* Always show gallery grid on mobile */
  .gallery-grid {
    display: flex !important;
  }
  
  /* Fix category header row for mobile */
  .category-header-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    margin: 0 0 15px 0 !important;
    padding: 10px !important;
  }
  
  /* Fix pagination for mobile - horizontal layout */
  .category-header-row .catnav,
  .catnav {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 5px !important;
    width: 100% !important;
  }
  
  .catnav .pgnum {
    min-width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 13px !important;
  }
  
  .catnav .pgnum a {
    line-height: 30px !important;
    padding: 0 8px !important;
  }
  
  /* Page info text on mobile */
  .catnav > span:last-child:not(.pgnum):not(.pgdots) {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    margin: 10px 0 0 0 !important;
  }
  
  /* Filter info on mobile */
  .category-header-row .filter_info,
  .filter_info {
    width: 100% !important;
    text-align: left !important;
  }
}

/* Search results - full width (no left nav on this page) */
.search-results .search-results-content {
  margin-top: 10px;
  margin-left: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.search-results .gallery-grid.active,
.search-results .search-gallery-grid.active {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
}

/* Search results gallery items - 5 per row like category gallery */
.search-results .gallery-item,
.search-gallery-grid .gallery-item {
  width: calc(20% - 10px) !important;
  flex: 0 0 calc(20% - 10px) !important;
  margin-bottom: 15px;
}

/* Search results images - match category gallery exactly */
.search-results .gallery-item-image,
.search-gallery-grid .gallery-item-image {
  height: 280px;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-results .gallery-item-image img,
.search-gallery-grid .gallery-item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Responsive for search results */
@media (max-width: 1200px) {
  .search-results .gallery-item,
  .search-gallery-grid .gallery-item {
    width: calc(25% - 10px) !important;
    flex: 0 0 calc(25% - 10px) !important;
  }
}

@media (max-width: 900px) {
  .search-results .gallery-item,
  .search-gallery-grid .gallery-item {
    width: calc(33.333% - 10px) !important;
    flex: 0 0 calc(33.333% - 10px) !important;
  }
}

@media (max-width: 600px) {
  .search-results .gallery-item,
  .search-gallery-grid .gallery-item {
    width: calc(50% - 8px) !important;
    flex: 0 0 calc(50% - 8px) !important;
  }
  
  .search-results .gallery-item-image,
  .search-gallery-grid .gallery-item-image {
    height: 220px;
  }
}

/* ================================================= */
/* MOBILE SPECIFIC FIXES                              */
/* ================================================= */

@media (max-width: 768px) {
  /* Hide content margin shift on mobile */
  #subpage_container #content {
    margin-left: 0 !important;
    padding: 0 10px !important;
  }
  
  /* Fix filter bar on mobile */
  #mobile_filter {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px !important;
    margin: 0 0 15px 0 !important;
  }
  
  #mobile_filter input[type="button"],
  #mobile_filter .filter3,
  #mobile_filter .filter4 {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: calc(50% - 4px) !important;
    padding: 10px 25px 10px 12px !important;
    font-size: 12px !important;
  }
  
  /* Hide desktop filter menu on mobile */
  .oe_wrapper,
  ul#oe_menu,
  #oe_menu {
    display: none !important;
  }
  
  /* Fix gallery grid container padding */
  .gallery-grid {
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Ensure gallery is always visible on mobile */
  #content .gallery-grid {
    display: flex !important;
  }
  
  /* Hide any leftover classic view elements */
  .filter_hint {
    display: none !important;
  }
  
  /* Fix header discount badge on mobile */
  .header_discount,
  .discount_badge,
  .promo_badge {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }
}

