/* Global Font Configuration */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* Explicitly define font-face for weight 800 to improve mobile support */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  /* Use a more reliable approach with font-variation-settings instead of direct URL */
  font-variation-settings: 'wght' 800;
  src: local('Inter ExtraBold'), local('Inter-ExtraBold');
}

/* Alpine.js x-cloak directive */
[x-cloak] {
  display: none !important;
}

:root {
  /* Font Family */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  
  /* Font Sizes */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.875vw, 2.25rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 2.25vw, 3rem);
  --text-5xl: clamp(3rem, 2.4rem + 3vw, 3.75rem);
  --text-6xl: clamp(3.75rem, 3rem + 3.75vw, 4.5rem);
}

/* Base Styles */
html {
  font-family: var(--font-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure proper font weight rendering on all devices */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Font weight utility classes with enhanced mobile support */
.font-bold {
  font-weight: 700 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-extrabold {
  font-weight: 800 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Ensure font weight is applied on mobile devices */
  font-synthesis: none;
  -webkit-font-feature-settings: "kern" 1;
  font-feature-settings: "kern" 1;
}

.font-black {
  font-weight: 900 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile-specific font weight fixes */
@media screen and (max-width: 768px) {
  .font-extrabold {
    font-weight: 800 !important;
    /* Force font weight on mobile browsers */
    -webkit-text-stroke: 0.01em transparent;
    text-shadow: 0 0 0 transparent;
  }
  
  /* Ensure headings maintain proper weight on mobile */
  h1.font-extrabold,
  h2.font-extrabold,
  h3.font-extrabold,
  h4.font-extrabold,
  h5.font-extrabold,
  h6.font-extrabold {
    font-weight: 800 !important;
    font-synthesis: weight;
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .font-extrabold {
    font-weight: 800 !important;
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* Responsive Typography */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-5xl { font-size: var(--text-5xl); }
.text-6xl { font-size: var(--text-6xl); }

/* Responsive Container */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

/* Responsive Images */
img {
  max-width: 100%;
  height: auto;
}

/* Responsive Tables */
table {
  width: 100%;
  overflow-x: auto;
  display: block;
}

/* Responsive Embeds */
.embed-responsive {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
}

.embed-responsive iframe,
.embed-responsive object,
.embed-responsive embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Print Styles */
@media print {
  body {
    font-size: 12pt;
  }
  
  .no-print {
    display: none !important;
  }
}

/* Custom Scrollbar Styles for Products Container */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #CBD5E0 #F7FAFC;
}

/* Webkit browsers (Chrome, Safari, Edge) */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #F7FAFC;
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #CBD5E0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #A0AEC0;
}

.custom-scrollbar::-webkit-scrollbar-corner {
  background: #F7FAFC;
}

/* Smooth scrolling behavior */
.custom-scrollbar {
  scroll-behavior: smooth;
}

/* Mobile scrollbar improvements */
@media (max-width: 768px) {
  .custom-scrollbar {
    -webkit-overflow-scrolling: touch;
  }
  
  .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
  }
}

/* Sticky Filter Sidebar */
.sticky-filter-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

/* Ensure filter sidebar scrollbar matches the main scrollbar */
.sticky-filter-sidebar {
  scrollbar-width: thin;
  scrollbar-color: #CBD5E0 #F7FAFC;
}

.sticky-filter-sidebar::-webkit-scrollbar {
  width: 6px;
}

.sticky-filter-sidebar::-webkit-scrollbar-track {
  background: #F7FAFC;
  border-radius: 3px;
}

.sticky-filter-sidebar::-webkit-scrollbar-thumb {
  background: #CBD5E0;
  border-radius: 3px;
  transition: background-color 0.2s ease;
}

.sticky-filter-sidebar::-webkit-scrollbar-thumb:hover {
  background: #A0AEC0;
}

/* Active Filters Container */
#activeFiltersContainer {
  transition: all 0.3s ease;
}

#activeFiltersContainer.has-filters {
  border-left: 4px solid #3B82F6;
}

#activeFiltersContainer.no-filters {
  opacity: 0.7;
}

/* Active Filter Badges */
.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background-color: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-badge:hover {
  background-color: #DBEAFE;
  border-color: #93C5FD;
}

.filter-badge .remove-btn {
  color: #6B7280;
  cursor: pointer;
  transition: color 0.2s ease;
}

.filter-badge .remove-btn:hover {
  color: #DC2626;
}

/* Responsive Active Filters */
@media (max-width: 640px) {
  #activeFilters {
    max-height: 120px;
    overflow-y: auto;
  }
}

/* Enhanced Search Bar Styles */
.search-container {
  position: relative;
}

.search-container .search-input {
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.search-container .search-input:focus {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.search-container .search-icon {
  transition: all 0.2s ease;
  z-index: 10;
}

.search-container:hover .search-icon {
  transform: scale(1.1);
}

.search-container .clear-search-btn {
  transition: all 0.2s ease;
  opacity: 0;
  transform: scale(0.8);
  z-index: 10;
}

.search-container .clear-search-btn:not(.hidden) {
  opacity: 1;
  transform: scale(1);
}

.search-container .clear-search-btn:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #DC2626;
  transform: scale(1.1);
  border-radius: 50%;
}

/* Search input placeholder animation */
.search-input::placeholder {
  transition: all 0.3s ease;
}

.search-input:focus::placeholder {
  opacity: 0.7;
  transform: translateX(4px);
}

/* Mobile search bar adjustments */
@media (max-width: 768px) {
  .search-container .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}