/* ============================================
   PRODUCTS PAGE RESPONSIVE STYLES
   Organized by Device Type for Easy Updates
   ============================================ */

/* ============================================
   BASE STYLES (All Devices)
   ============================================ */
.products-page-container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

/* ============================================
   MOBILE DEVICES (0px - 640px)
   ============================================ */
@media (max-width: 640px) {
  /* Container & Layout */
  .products-page-container {
    padding: 0.75rem;
  }

  .products-page-main {
    flex-direction: column;
    gap: 1rem;
  }

  /* Hide Desktop Sidebar on Mobile */
  .desktop-sidebar {
    display: none !important;
  }

  /* Mobile Filter Trigger Button - Windows 11 Glass */
  .mobile-filter-trigger {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9998;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-shadow: 
      0 8px 32px 0 rgba(31, 38, 135, 0.4),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
  }
  
  .mobile-filter-trigger:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.1);
    box-shadow: 
      0 12px 40px 0 rgba(31, 38, 135, 0.5),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.6);
  }
  
  .mobile-filter-trigger:active {
    transform: scale(0.95);
  }

  .mobile-filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    border: 2px solid white;
  }

  /* Mobile Sidebar Filters - Full Screen Modal Design */
  .mobile-sidebar-filters {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
  }

  .mobile-sidebar-filters.hidden {
    display: none !important;
  }

  .mobile-sidebar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    animation: fadeIn 0.3s ease;
  }

  .mobile-sidebar-content {
    position: relative;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
    border-top-left-radius: 2rem;
    border-top-right-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
      0 -8px 32px 0 rgba(31, 38, 135, 0.3),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Mobile Sidebar Header - Windows 11 Glass */
  .mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: rgba(37, 99, 235, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.2);
  }

  .mobile-sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
  }

  .mobile-sidebar-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.75rem;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
  }

  .mobile-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.15);
  }

  /* Mobile Sidebar Body */
  .mobile-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-bottom: 6rem;
  }

  .mobile-filter-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  /* Mobile Filter Sections */
  .mobile-filter-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-filter-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
  }

  .mobile-filter-icon {
    color: #2563eb;
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
  }

  .mobile-filter-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.15);
  }

  .mobile-filter-input:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.5);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 
      0 0 0 3px rgba(37, 99, 235, 0.2),
      0 4px 12px 0 rgba(31, 38, 135, 0.2);
  }

  /* Mobile Price Inputs */
  .mobile-price-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mobile-price-inputs .mobile-filter-input {
    flex: 1;
  }

  .mobile-price-separator {
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
  }

  .mobile-price-info {
    font-size: 0.875rem;
    color: #6b7280;
    padding-left: 2rem;
  }

  /* Mobile Category Filter */
  .mobile-filter-toggle {
    width: 100%;
    padding: 1rem;
    background: rgba(239, 246, 255, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(191, 219, 254, 0.5);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.15);
  }

  .mobile-filter-toggle:active {
    background: rgba(219, 234, 254, 0.8);
    transform: scale(0.98);
  }

  .mobile-filter-toggle-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
  }

  .mobile-filter-badge-small {
    background: #2563eb;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .mobile-filter-chevron {
    color: #2563eb;
    transition: transform 0.3s ease;
  }

  .mobile-filter-chevron.rotate-180 {
    transform: rotate(180deg);
  }

  .mobile-category-content {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .mobile-category-content.hidden {
    display: none;
  }

  .mobile-filter-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: rgba(249, 250, 251, 0.6);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(229, 231, 235, 0.4);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.75rem;
    box-shadow: 0 2px 6px 0 rgba(31, 38, 135, 0.1);
  }

  .mobile-filter-option:active {
    transform: scale(0.98);
  }

  .mobile-filter-option.active {
    background: rgba(239, 246, 255, 0.8);
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 4px 12px 0 rgba(37, 99, 235, 0.2);
  }

  .mobile-filter-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #2563eb;
  }

  .mobile-filter-option-text {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    color: #1f2937;
  }

  .mobile-filter-option-icon {
    color: #6b7280;
    width: 20px;
    text-align: center;
  }

  .mobile-filter-check {
    color: #2563eb;
    font-size: 1.25rem;
  }

  /* Mobile Checkbox Labels */
  .mobile-filter-checkbox-label {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: rgba(249, 250, 251, 0.6);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(229, 231, 235, 0.4);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px 0 rgba(31, 38, 135, 0.1);
  }

  .mobile-filter-checkbox-label:active {
    transform: scale(0.98);
  }

  .mobile-filter-checkbox-label.featured {
    background: rgba(254, 252, 232, 0.7);
    border-color: rgba(253, 224, 71, 0.5);
    box-shadow: 0 2px 8px 0 rgba(253, 224, 71, 0.2);
  }

  .mobile-filter-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: #2563eb;
  }

  .mobile-filter-checkbox-label.featured .mobile-filter-checkbox {
    accent-color: #eab308;
  }

  .mobile-filter-checkbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: #1f2937;
  }

  /* Mobile Sidebar Footer - Windows 11 Glass */
  .mobile-sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    box-shadow: 
      0 -4px 16px 0 rgba(31, 38, 135, 0.2),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
  }

  .mobile-filter-clear,
  .mobile-filter-apply {
    flex: 1;
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  .mobile-filter-clear {
    background: rgba(243, 244, 246, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    color: #374151;
    border: 1px solid rgba(229, 231, 235, 0.4);
    box-shadow: 0 2px 8px 0 rgba(31, 38, 135, 0.15);
  }

  .mobile-filter-clear:active {
    background: rgba(229, 231, 235, 0.8);
    transform: scale(0.98);
  }

  .mobile-filter-apply {
    background: rgba(37, 99, 235, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    color: white;
    border: 1px solid rgba(37, 99, 235, 0.3);
    box-shadow: 0 4px 12px 0 rgba(37, 99, 235, 0.3);
  }

  .mobile-filter-apply:active {
    background: rgba(29, 78, 216, 0.9);
    transform: scale(0.98);
  }

  /* Products Container - Mobile */
  #products-container {
    width: 100%;
    padding: 0;
  }

  /* App Products Header - Mobile */
  .app-products-header {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
  }

  .app-page-title {
    font-size: 1.5rem;
  }

  .app-header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .app-sort-container {
    flex: 1;
    min-width: 0;
  }

  .app-sort-select {
    flex: 1;
    min-width: 0;
  }

  /* App Products Grid - Mobile */
  .app-products-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .app-product-card {
    margin-bottom: 0;
  }

  /* List View - Mobile */
  .app-products-grid.list-view .app-product-card {
    flex-direction: column;
  }

  .app-products-grid.list-view .app-product-image-wrapper {
    width: 100%;
  }

  /* Load More Button - Mobile */
  #load-more-container {
    padding: 1rem 0;
  }

  #load-more-btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 0.875rem;
  }

}

/* ============================================
   DESKTOP SIDEBAR STYLES (641px and above)
   ============================================ */
@media (min-width: 641px) {
  /* Hide Mobile Filter Button on Desktop */
  .mobile-filter-trigger,
  .mobile-sidebar-filters {
    display: none !important;
  }

  /* Desktop Sidebar - Always Visible */
  .desktop-sidebar {
    display: block !important;
  }

  /* Desktop Sidebar Specific Styles */
  .desktop-sidebar #sidebar-content {
    position: sticky;
    top: 6rem;
  }

  .desktop-sidebar .sidebar-content-wrapper {
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
  }
}

/* ============================================
   TABLET DEVICES (641px - 1024px)
   ============================================ */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Container & Layout */
  .products-page-container {
    padding: 1rem;
  }

  .products-page-main {
    flex-direction: row;
    gap: 1.5rem;
  }

  /* Sidebar - Tablet */
  .sidebar-filters {
    width: 240px !important;
    flex-shrink: 0;
  }

  .sidebar-filters.collapsed {
    width: 72px !important;
  }

  /* Sidebar Content - Tablet */
  .sidebar-content-wrapper {
    padding: 1.25rem !important;
  }

  .sidebar-toggle-text {
    font-size: 0.875rem;
  }

  /* Filter Sections - Tablet */
  .filter-section {
    margin-bottom: 1.5rem;
  }

  .filter-section label {
    font-size: 0.875rem;
  }

  /* Category Filter - Tablet */
  .category-filter-content {
    max-height: 350px;
  }

  /* Products Container - Tablet */
  #products-container {
    flex: 1;
    min-width: 0;
  }

  /* Products Header - Tablet */
  .products-header {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
  }

  .products-header h1 {
    font-size: 1.75rem;
  }

  /* Sort & Layout Controls - Tablet */
  .products-controls {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .products-controls > div {
    flex: 0 1 auto;
  }

  /* App Products Grid - Tablet */
  .app-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem;
  }

  .app-products-grid.compact-view {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem;
  }

  /* List View - Tablet */
  .app-products-grid.list-view .app-product-card {
    flex-direction: row;
  }

  .app-products-grid.list-view .app-product-image-wrapper {
    width: 200px;
    flex-shrink: 0;
  }

  /* Load More Button - Tablet */
  #load-more-btn {
    padding: 1rem 2rem;
  }
}

/* ============================================
   DESKTOP DEVICES (1025px and above)
   ============================================ */
@media (min-width: 1025px) {
  /* Container & Layout */
  .products-page-container {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
  }

  .products-page-main {
    flex-direction: row;
    gap: 2rem;
  }

  /* Sidebar - Desktop */
  .sidebar-filters {
    width: 256px !important;
    flex-shrink: 0;
  }

  .sidebar-filters.collapsed {
    width: 80px !important;
  }

  /* Sidebar Content - Desktop */
  .sidebar-content-wrapper {
    padding: 1.5rem !important;
  }

  /* Filter Sections - Desktop */
  .filter-section {
    margin-bottom: 1.5rem;
  }

  /* Category Filter - Desktop */
  .category-filter-content {
    max-height: 400px;
  }

  /* Products Container - Desktop */
  #products-container {
    flex: 1;
    min-width: 0;
  }

  /* Products Header - Desktop */
  .products-header {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .products-header h1 {
    font-size: 2rem;
  }

  /* Sort & Layout Controls - Desktop */
  .products-controls {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
  }

  /* App Products Grid - Desktop */
  .app-products-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.5rem;
  }

  .app-products-grid.compact-view {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.25rem;
  }

  /* List View - Desktop */
  .app-products-grid.list-view .app-product-card {
    flex-direction: row;
  }

  .app-products-grid.list-view .app-product-image-wrapper {
    width: 250px;
    flex-shrink: 0;
  }

  /* Load More Button - Desktop */
  #load-more-btn {
    padding: 1rem 3rem;
    font-size: 1rem;
  }
}

/* ============================================
   LARGE DESKTOP (1440px and above)
   ============================================ */
@media (min-width: 1440px) {
  .products-page-container {
    max-width: 1600px;
  }

  .app-products-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .app-products-grid.compact-view {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* ============================================
   UTILITY CLASSES (All Devices)
   ============================================ */
.products-page-main {
  display: flex;
  width: 100%;
}

/* Legacy support - can be removed after testing */
.products-header {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.products-controls {
  display: flex;
  align-items: center;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar-filters,
  .products-controls,
  .layout-switcher,
  #load-more-container {
    display: none !important;
  }

  .app-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .app-product-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
