/* Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;700&family=Inconsolata:wght@400;700&display=swap');

/* Ensure full height for root elements */
html, body {
  height: 100%;
  margin: 0; /* Prevent default margins */
  padding: 0; /* Prevent default padding */
  /* Prevent body scrolling when modal is open - enhanced for mobile */
}

/* Enhanced body scroll prevention for mobile */
body.kb-modal-open,
html.kb-modal-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
  /* iOS Safari specific fixes */
  -webkit-overflow-scrolling: touch !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
}

/* Fast transitions for category buttons */
.category-nav-btn, 
[class*="category"], 
[class*="nav-btn"] {
  transition: all 0.1s ease !important; /* Faster animation for bold/unbold */
}

/* Category navigation horizontal scrolling */
.kb-category-nav, 
[class*="category-nav"] {
  display: flex !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scroll-behavior: smooth !important;
  white-space: nowrap !important;
  -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
}

/* Hide scrollbar but keep functionality */
.kb-category-nav::-webkit-scrollbar,
[class*="category-nav"]::-webkit-scrollbar {
  height: 0px !important;
  background: transparent !important;
}

/* Customizer Button Styles */
.kb-customizer-3-container {
  margin: 20px 0;
  text-align: center;
}

.kb-customizer-3-button {
  display: inline-block;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;

  /* Specific styles requested */
  background-color: #EDD286 !important;
  border: solid 0.2rem #44422c !important;
  border-radius: 24px !important;
  color: #44422c !important;
  font-family: 'Inconsolata', monospace; /* Use Inconsolata, fallback to generic monospace */
  font-weight: 700; /* Use 700 for bold */
  text-transform: uppercase;
}

.kb-customizer-3-button:hover {
  box-shadow: 4px 4px #44422c;
}

/* KB Customizer 3 Styles */

/* Global Variables & Base Styles */
:root {
  --heading-s-alt-font-family: 'Oswald', sans-serif;
  --heading-s-alt-font-size: 22px;
  --heading-s-alt-line-height: 26px;
  --heading-s-alt-letter-spacing: 0.08px;
  --heading-s-alt-font-weight: 500;
  --brand-light-gold: #edd286;
  --brand-brown: #44422c;
  --brand-dark-green: #316549;
  --bg-cream: #EAE6DD;
  --bg-preview: #f0f0f0;
}

.kb-customizer-3 * {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Modal Styles */
.kb-customizer-3-modal {
  position: fixed;
  z-index: 999999;
  left: 0;
  top: 0;
  width: 100vw; /* Use viewport width for full coverage */
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Dynamic viewport height for modern browsers */
  min-height: 100vh; /* Fallback for older browsers */
  min-height: 100dvh; /* Dynamic viewport height minimum */
  background-color: rgba(0, 0, 0, 0.5);
  display: none; /* Initially hidden */
  align-items: center;
  justify-content: center;
}

.kb-customizer-3-modal.visible {
    display: flex; /* Show when visible class is added */
}

.kb-customizer-3-modal-content {
  background-color: #fff;
  width: 90%;
  max-width: 1200px;
  height: 80%;
  max-height: 800px;
  border-radius: 8px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  display: flex; /* For layout container */
  flex-direction: column; /* For overall structure */
}

.kb-customizer-layout-container {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.kb-customizer-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: var(--brand-dark-green);
  z-index: 10;
}

/* Sidebar Styles */
.kb-sidebar {
  width: 33.33%;
  min-width: 33.33%; /* Prevent shrinking */
  max-width: 33.33%; /* Prevent growing - added important for override */
  flex-basis: 33.33%; /* Ensure exact width */
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--brand-dark-green);
  background-color: var(--bg-cream);
  position: relative; /* Changed from absolute */
  height: 100%; /* Ensure it fills the container height */
  overflow: hidden; /* Prevent internal scrollbars initially */
}


/* Patch Navigation (Top Bar in Sidebar) */
.kb-patch-nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 2px solid var(--brand-dark-green);
  background-color: var(--bg-cream);
  width: 100%;
  flex-shrink: 0; /* Prevent shrinking */
}

.kb-patch-nav-arrow {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--brand-dark-green);
  transition: opacity 0.3s ease;
  opacity: 1; /* Default visible */
  font-family: 'Inconsolata-Regular', 'Inconsolata', sans-serif;
  font-size: 16px;
  line-height: 20px;
  font-weight: 400;
  text-transform: uppercase;
}

.kb-patch-nav-arrow.hidden {
  /* opacity: 0; */ /* Changed from opacity */
  visibility: hidden; /* Use visibility to hide but retain space */
  pointer-events: none; /* Make unclickable when hidden */
}

/* Push next button right when previous button is hidden */
.kb-patch-nav-prev.hidden + .kb-patch-nav-next {
  margin-left: auto;
}

.kb-patch-nav-arrow span:first-child { /* Arrow icon */
  font-size: 16px;
}

.kb-patch-nav-prev span:first-child {
  margin-right: 5px;
}

.kb-patch-nav-next span:last-child {
  margin-left: 5px;
}

/* Category Navigation (Below Patch Nav) */
.kb-category-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px;
  gap: 16px;
  border-bottom: 2px solid var(--brand-dark-green);
  background-color: var(--bg-cream);
  white-space: nowrap;
  scroll-behavior: smooth;
  -ms-overflow-style: none;  /* Hide scrollbar IE/Edge */
  scrollbar-width: none;   /* Hide scrollbar Firefox */
  width: 100%;
  flex-shrink: 0; /* Prevent shrinking */
}

.kb-category-nav::-webkit-scrollbar {
  display: none; /* Hide scrollbar Chrome/Safari/Opera */
}

.category-nav-btn {
  box-sizing: border-box;
  color: var(--brand-dark-green);
  text-align: left;
  font-family: 'Oswald-Regular', 'Oswald', sans-serif;
  font-size: 22px;
  line-height: 26px;
  letter-spacing: 0.08px;
  font-weight: 400;
  text-transform: uppercase;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: all 0.15s ease;
  /* Styles for nowrap behavior */
  white-space: nowrap;
  display: inline-block;
  overflow: visible;
  text-overflow: unset;
  flex-shrink: 0;
}

.category-nav-btn.active {
  font-weight: 700;
}

/* Design Gallery (Main Area in Sidebar) */
.kb-design-gallery {
  flex: 1; /* Take remaining space */
  overflow-y: auto; /* Allow vertical scrolling ONLY */
  overflow-x: hidden; /* Hide horizontal scrollbar */
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); /* Adjusted minmax for item size */
  gap: 15px;
  align-content: flex-start;
  background-color: var(--bg-cream);
  width: 100%; /* Ensure it takes full width */
}

.design-item {
  width: 72px;
  height: auto; /* Allow height to expand for text */
  cursor: pointer;
  background-color: transparent;
  display: flex;
  flex-direction: column; /* Stack image and text vertically */
  align-items: center;
  padding: 4px;
  box-sizing: border-box;
}

.design-item-image {
  width: 64px;
  height: 64px;
  border: 2px solid transparent; /* Start transparent for hover effect */
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent; /* Remove white background */
  margin-bottom: 4px;
  transition: border 0.2s ease, box-shadow 0.2s ease; /* Smooth transition */
}

.design-item-label {
  font-size: 10px;
  color: var(--brand-brown);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block; /* Remove extra space below image */
}

.design-item:hover .design-item-image {
  border: 2px solid var(--brand-dark-green);
}

.design-item.selected .design-item-image {
  border: 2px solid var(--brand-dark-green);
}

/* Prevent hover border when item is currently selected (has outline) */
.design-item.currently-selected:hover .design-item-image {
  border: 2px solid transparent !important; /* Remove hover border to prevent double stroke with outline */
}

/* Second subpatch hover animation styles */
.design-item-image {
  position: relative; /* Ensure proper positioning context */
}

.second-subpatch-image {
  pointer-events: none; /* Don't interfere with clicking */
  will-change: transform; /* Optimize for animations */
}

/* Ensure parent patches with subpatches have proper layering */
.design-item.has-subpatches .design-item-image {
  z-index: 1; /* Ensure main image stays on top */
}

/* Monogram Input Styles */
.monogram-input-container {
  padding: 0; /* Remove padding since parent .kb-design-gallery already has 20px */
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  display: block; /* Override the parent grid display */
  grid-column: 1 / -1; /* Span all grid columns if grid is still applied */
}

.monogram-description {
  color: var(--brand-brown);
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: normal;
  text-align: left;
  width: 100%;
}

.monogram-input-field {
  width: 100%;
  max-width: none; /* Remove any inherited max-width constraints */
  height: 40px;
  font-size: 12px; /* Reduced from 24px (50% smaller) */
  font-family: 'Oswald', Arial, sans-serif; /* Match placeholder font */
  font-weight: 600; /* Match placeholder weight */
  text-align: left;
  padding-left: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #f0f0f0;
  color: var(--brand-brown);
  letter-spacing: 2px; /* Reduced from 4px to match smaller font */
  margin-bottom: 15px;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center; /* Vertically center text */
}

.monogram-input-field:hover {
  background-color: #E8E7E7;
  border-color: #316549;
}

.monogram-input-field:focus {
  outline: none;
  background-color: #E8E7E7;
  border: 2px solid #2D5A4C;
  box-shadow: 0 0 0 2px rgba(45, 90, 76, 0.2);
}

.monogram-input-field::placeholder {
  font-family: 'Oswald', Arial, sans-serif;
  font-weight: 600;
  font-size: 12px; /* Match input text size */
  color: #999;
  letter-spacing: 2px; /* Match input text letter spacing */
}

/* Font Grid Styles */
.monogram-font-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.font-option {
  background-color: #F8F8F8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.font-option:hover {
  background-color: #f0f0f0;
  border-color: #316549;
}

.font-option.selected {
  background-color: #F8F8F8;
  border: 2px solid #316549;
}

.font-name {
  font-size: 16px;
  color: var(--brand-brown);
  font-weight: bold;
  line-height: 1.2;
}

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;600&display=swap');

/* Custom Font Faces - Loading from Shopify Content > Files */
@font-face {
  font-family: 'Princetown';
  src: url('https://cdn.shopify.com/s/files/1/0711/5862/8632/files/princetown.ttf?v=1') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OldEnglish';
  src: url('https://cdn.shopify.com/s/files/1/0711/5862/8632/files/old-english.ttf?v=1') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Font preview styles */
.font-impact { font-family: 'Impact', Arial Black, sans-serif; }
.font-brush { font-family: 'Brush Script MT', 'Lucida Handwriting', cursive; }
.font-princetown { font-family: 'Princetown', 'Times New Roman', serif; }
.font-old-english { 
  font-family: 'OldEnglish', 'Old English Text MT', fantasy; 
}

/* Remove Patch Text Link Styles */
.kb-remove-patch-container {
  padding: 4px 8px;
  margin: 0px;
  text-align: center;
}

.kb-remove-patch-btn {
  background: none;
  border: none;
  color: #316549;
  font-family: 'Inconsolata', monospace;
  font-size: 12px;
  font-weight: normal;
  cursor: pointer;
  text-decoration: underline;
  transition: all 0.2s ease;
  padding: 0;
}

.kb-remove-patch-btn:hover {
  color: #2D5A4C;
  text-decoration: none;
}

.kb-remove-patch-btn:active {
  color: #1F3D32;
}

/* Reduce Old English text size in selector by 20% */
.font-old-english .font-name {
  font-size: 12.8px; /* 16px * 0.8 = 12.8px (20% smaller) */
}

/* Color Grid Styles */
.monogram-color-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 12px;
  margin-bottom: 15px;
  width: 100% !important;
  padding: 5px;
  box-sizing: border-box;
}

.color-option {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
}

.color-circle {
  width: 48px !important; /* Reduced by 20% from 60px */
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  border-radius: 50% !important;
  border: 2px solid transparent !important;
  transition: all 0.2s ease;
  margin-bottom: 6px; /* Increased from 4px to 6px for 2px more spacing */
  display: block !important;
  position: relative !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

.color-name {
  font-size: 10px;
  color: var(--brand-brown);
  font-weight: normal;
  line-height: 1;
  text-align: center;
}

.color-option:hover .color-circle {
  transform: scale(1.1);
  border-color: #2D5A4C;
}

.color-option.selected .color-circle {
  border: 2px solid #2D5A4C !important;
  transform: scale(1.15);
}

.monogram-preview {
  margin-top: 10px;
  font-size: 18px;
  color: var(--brand-dark-green);
  font-weight: bold;
  font-family: 'Inconsolata', monospace;
  letter-spacing: 3px;
  text-align: center;
  width: 100%;
}

/* Sidebar Button Area (Bottom) */
.kb-sidebar-button-container {
  padding: 12px;
  border-top: 2px solid var(--brand-dark-green);
  text-align: center;
  background-color: var(--bg-cream);
  flex-shrink: 0; /* Prevent shrinking */
  width: 100%;
}

.kb-add-to-cart-btn {
  background: var(--brand-light-gold);
  border-radius: 40px;
  border: 2px solid var(--brand-brown);
  padding: 20px 32px;
  display: inline-flex; /* Use inline-flex for centering if needed */
  flex-direction: row;
  gap: 12px;
  align-items: center;
  justify-content: center;
  height: 55px;
  color: var(--brand-brown);
  text-align: center;
  font-family: 'Inconsolata-Bold', 'Inconsolata', sans-serif;
  font-size: 16px;
  line-height: 20px;
  letter-spacing: 0.24px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  margin: 0 auto;
  position: relative; /* For potential pseudo-elements */
  box-shadow: none; /* Default state */
}

.kb-add-to-cart-btn:hover {
  box-shadow: 4px 4px 0px 0px var(--brand-brown);
}

/* Preview Area Styles */
.kb-preview-area {
  width: 66.67%;
  min-width: 66.67%; /* Prevent shrinking */
  max-width: 66.67%; /* Prevent growing */
  flex-basis: 66.67%; /* Ensure exact width */
  flex-shrink: 0;
  flex-grow: 0;
  position: relative; /* Changed from absolute */
  height: 100%; /* Fill container height */
  background-color: var(--bg-preview);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* Hide overflow */
}

.kb-preview-image-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex; /* Center image */
  align-items: center;
  justify-content: center;
}

.kb-product-preview-image {
  max-width: 100%;
  max-height: calc(100% - 40px); /* Adjust max-height to prevent overflow, e.g., 800px * 0.8 height - padding */
  height: auto; /* Maintain aspect ratio */
  display: block; /* Remove extra space */
  object-fit: contain; /* Ensure image fits */
}

.kb-design-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allow clicks through overlay itself */
  overflow: hidden; /* Clip patches if they exceed bounds */
}

.kb-overlay-patch-img {
  position: absolute;
  transform: translate(-50%, -50%); /* Center the patch */
  object-fit: contain;
  pointer-events: auto; /* Make patches clickable */
  cursor: pointer;
  z-index: 10;
  /* Removed transition to prevent resize animation */
  /* Size will be set via inline style */
}

.kb-overlay-patch-img:hover {
  z-index: 15;
}


.kb-overlay-patch-text {
  pointer-events: auto;
  cursor: pointer;
}



/* Zoom Icon Styles (Mobile Only) */
.kb-zoom-icon {
  display: none; /* Hidden by default (desktop) */
}

@media (max-width: 768px) {
  .kb-zoom-icon {
    display: block;
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  
  .kb-zoom-icon:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
  }
  
  .kb-zoom-icon.zoomed {
    background-color: rgba(255, 255, 255, 1);
  }
  
  .kb-zoom-icon img {
    width: 15px;
    height: 15px;
    object-fit: contain;
  }
  
  /* Zoom states for preview area */
  .kb-preview-area.zoomed {
    overflow: hidden !important;
  }
  
  .kb-preview-image-container.zoomed {
    transform-origin: center center;
    transition: transform 0.4s ease;
  }
  
  .kb-preview-image-container {
    transition: transform 0.4s ease;
  }
}

/* Mobile & Medium Screen Styles (max-width: 672px) - Mobile layout for both */
@media (max-width: 672px) {
  .kb-customizer-3-modal {
    padding: 0 !important;
    margin: 0 !important;
    inset: 0 !important; /* Modern way to set top, right, bottom, left to 0 */
    width: 100vw !important;
    height: 100vh !important; /* Fallback for older browsers */
    height: 100dvh !important; /* Dynamic viewport height for iOS Safari */
    min-height: 100vh !important; /* Fallback for older browsers */
    min-height: 100dvh !important; /* Dynamic viewport height minimum */
    background-color: rgba(0, 0, 0, 0.8) !important; /* Darker background for mobile */
    touch-action: none !important; /* Prevent touch scrolling/gestures */
    overscroll-behavior: none !important; /* Prevent overscroll bounce */
    -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
    /* iOS Safe Area support */
    padding-top: env(safe-area-inset-top) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    padding-left: env(safe-area-inset-left) !important;
    padding-right: env(safe-area-inset-right) !important;
  }

  .kb-customizer-3-modal-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important; /* Fallback for older browsers */
    height: 100dvh !important; /* Dynamic viewport height for iOS Safari */
    max-height: none !important;
    min-height: 100vh !important; /* Fallback for older browsers */
    min-height: 100dvh !important; /* Dynamic viewport height minimum */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    position: relative !important; /* Ensure proper positioning */
    /* Compensate for safe area padding from parent */
    box-sizing: border-box !important;
  }

  .kb-customizer-layout-container {
    flex-direction: column-reverse !important; /* Stack preview on top, sidebar below */
    height: 100% !important; /* Use percentage height relative to modal content */
    max-height: 100vh !important; /* Fallback for older browsers */
    max-height: 100dvh !important; /* Dynamic viewport height for iOS Safari */
    overflow: hidden !important;
  }

  /* Sidebar becomes bottom panel */
  .kb-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto !important; /* Adjust height automatically based on content */
    max-height: 50vh !important; /* Limit height */
    overflow-y: auto !important; /* Allow scroll if content exceeds max-height */
    border-right: none !important;
    border-top: 2px solid var(--brand-dark-green) !important;
    flex-basis: auto !important; /* Reset flex basis */
    position: relative !important; /* Ensure it's in flow */
  }

  /* Preview area covers top portion */
  .kb-preview-area {
    width: 100% !important;
    max-width: 100% !important;
    /* height: 50vh !important; */ /* Restore fixed height - REMOVING THIS */
    /* min-height: 50vh !important; */ /* Restore fixed min-height - REMOVING THIS */
    flex: 1 !important; /* Allow preview to grow and fill space */
    min-height: 0 !important; /* Prevent flex overflow issues */
    background-color: var(--bg-preview) !important;
    position: relative !important; /* Ensure it's in flow */
    display: flex !important; /* Keep flex properties for centering */
  }

  .kb-product-preview-image {
     max-height: 100% !important; /* Allow image to fill preview area height on mobile */
     max-width: 100% !important;
  }

  /* Adjustments for elements within sidebar */
  .kb-patch-nav-container {
    padding: 8px !important;
    border-bottom: none !important; /* Remove bottom border */
    /* border-top: none !important; Assume top border is handled by .kb-sidebar */
    /* margin-top: auto !important; */ /* REMOVED: No longer needed here */
  }

  .kb-category-nav {
    border-top: 2px solid var(--brand-dark-green) !important;
    border-bottom: 2px solid var(--brand-dark-green) !important;
    padding: 0px !important; /* Changed to 0px padding */
    gap: 0px !important; /* Changed to 0px gap */
  }

  /* Design gallery - horizontal scrolling with flexible height */
  .kb-design-gallery {
    border-top: none !important;
    padding: 10px 12px !important; /* Changed to 10px 12px */
    display: flex !important; /* Change to flex for horizontal scroll */
    flex-wrap: nowrap !important;
    grid-template-columns: none !important; /* Remove grid */
    overflow-x: auto !important;
    overflow-y: auto !important; /* Allow vertical scroll for monogram content */
    white-space: nowrap !important;
    gap: 16px !important;
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
    align-content: unset !important; /* Unset grid property */
    /* Removed fixed height constraints to allow flexible height */
  }

  .kb-design-gallery::-webkit-scrollbar {
    display: none !important; /* Hide scrollbar */
  }

  /* Design items in horizontal scroll */
  .design-item {
    margin-right: 0 !important; /* Gap handled by flex container */
    margin-bottom: 0 !important;
    min-width: 56px !important;
    width: 56px !important;
    height: 80px !important; /* Changed to 80px */
    padding: 0 !important;
    flex-shrink: 0 !important; /* Prevent items from shrinking */
    border-width: 1px !important; /* Thinner border */
  }

  /* Make patches in preview smaller */
  .kb-overlay-patch-img {
     /* Sizes are handled by JS based on isMobile */
     /* We'll adjust the size in the selectDesign function */
  }

  /* "Add to Cart" button adjustments */
  .kb-sidebar-button-container {
    padding: 12px !important;
  }

  .kb-add-to-cart-btn {
    height: 50px !important;
    padding: 15px 25px !important;
    width: 100% !important; /* Full width */
    margin: 0 !important;
    font-size: 14px !important; /* Slightly smaller text */
  }

  /* Mobile category nav buttons styling */
  .category-nav-btn {
    font-size: 22px !important; /* Changed to 22px */
    line-height: 23px !important; /* Increased proportionally */
    padding: 10px 12px !important; /* Changed to 10px 12px */
    min-height: auto !important; /* Allow natural height */
    white-space: nowrap !important; /* Prevent text wrapping */
    overflow: visible !important; /* Show full text */
    text-overflow: clip !important; /* Don't add ellipsis */
    transition: all 0.1s ease !important; /* Faster animation for bold/unbold */
    flex-shrink: 0 !important; /* Prevent buttons from shrinking in horizontal scroll */
  }
  
  /* Mobile patch navigation improvements */
  .kb-patch-nav-container {
    padding: 10px 12px !important; /* Changed to 10px 12px */
    min-height: 44px !important; /* Increase minimum height */
    overflow: visible !important; /* Ensure text is not clipped */
  }
  
  .kb-patch-nav-arrow {
    font-size: 15px !important; /* Slightly larger font for readability */
    line-height: 20px !important; /* Better line height */
    padding: 6px 8px !important; /* More padding for touch targets */
    white-space: nowrap !important; /* Prevent text wrapping */
    overflow: visible !important; /* Show full text */
    flex-shrink: 0 !important; /* Prevent shrinking */
  }
  
  .kb-patch-nav-arrow span:first-child {
    font-size: 16px !important; /* Larger arrow icons for better visibility */
  }
  
  .kb-patch-nav-arrow span:last-child {
    margin-left: 6px !important; /* More space between arrow and text */
  }
  
  /* Mobile monogram container adjustments */
  .monogram-input-container {
    height: 100% !important; /* Fill available height */
    overflow-y: auto !important; /* Allow vertical scrolling */
    padding: 8px !important; /* Reduce padding for mobile */
    white-space: normal !important; /* Allow text wrapping */
    display: block !important; /* Override flex for vertical layout */
  }
  
  .monogram-font-grid,
  .monogram-color-grid {
    white-space: normal !important; /* Allow normal wrapping */
  }
} 

/* Loading Overlay */
.kb-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  z-index: 10; /* Ensure it's above other modal content */
  font-size: 1.2em;
  color: #333;
}

.kb-loading-overlay.visible {
  display: flex; /* Show when visible class is added */
}

/* Simple Spinner */
.kb-spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: var(--brand-primary, #008060);
  animation: spin 1s ease infinite;
  margin-right: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Medium Screen Specific Styles (472px - 672px) - Override image sizing for tablets */
@media (min-width: 472px) and (max-width: 672px) {
  .kb-product-preview-image {
     max-height: 80vh !important; /* Fit image within viewport height for medium screens */
     max-width: 80% !important; /* Fit image within 80% of container width for better spacing */
     object-fit: contain !important; /* Ensure proper scaling without stretching */
     width: auto !important; /* Allow width to adjust to maintain aspect ratio */
     height: auto !important; /* Allow height to adjust to maintain aspect ratio */
  }

  .kb-overlay-patch-img {
     /* Medium screen scaling handled by JavaScript */
  }
}