/* Reset and Base Styles */
:root {
  --primary: #f97316; /* orange-500 */
  --primary-hover: #ea580c; /* orange-600 */
  --bg-color: #f8fafc; /* slate-50 */
  --surface: #ffffff;
  --text-main: #0f172a; /* slate-900 */
  --text-muted: #64748b; /* slate-500 */
  --text-light: #94a3b8; /* slate-400 */
  --border: #e2e8f0; /* slate-200 */
  --border-focus: #cbd5e1; /* slate-300 */
  
  --success-bg: #ecfdf5; /* emerald-50 */
  --success-text: #047857; /* emerald-700 */
  --success-dot: #10b981; /* emerald-500 */
  --success-border: rgba(5, 150, 105, 0.2);
  
  --error-bg: #fef2f2; /* red-50 */
  --error-text: #b91c1c; /* red-700 */
  --error-dot: #ef4444; /* red-500 */
  --error-border: rgba(220, 38, 38, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  background-color: var(--bg-color);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Custom Scrollbar for a premium feel */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9; 
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1; 
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8; 
}

/* Utility */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.container {
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 0 2rem; } }

/* Navbar */
.navbar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.navbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 4rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.brand-icon {
  font-size: 1.875rem;
  color: var(--primary);
}
.brand-text {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  color: var(--text-main);
}
.brand-text span {
  color: var(--primary);
}

/* Search */
.search-wrapper {
  flex: 1;
  max-width: 42rem;
  padding: 0 2rem;
  display: none;
}
@media (min-width: 768px) { .search-wrapper { display: block; } }
.search-input-group {
  position: relative;
}
.search-icon {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  padding-left: 0.75rem;
  display: flex;
  align-items: center;
  pointer-events: none;
  color: var(--text-light);
  font-size: 1.125rem;
}
.search-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  border: 1px solid var(--border-focus);
  border-radius: 9999px;
  line-height: 1.25;
  background-color: #f8fafc;
  color: var(--text-main);
  transition: all 0.2s;
  font-size: 0.875rem;
  outline: none;
}
.search-input::placeholder {
  color: var(--text-light);
}
.search-input:focus {
  background-color: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

/* Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.toggle-wrapper {
  position: relative;
}
.toggle-bg {
  display: block;
  background-color: var(--border);
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  transition: background-color 0.3s;
}
.toggle-input:checked + .toggle-bg {
  background-color: var(--primary);
}
.toggle-dot {
  position: absolute;
  left: 0.25rem;
  top: 0.25rem;
  background-color: var(--surface);
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  transition: transform 0.3s;
}
.toggle-input:checked ~ .toggle-dot {
  transform: translateX(1rem);
}
.toggle-text {
  margin-left: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  display: none;
}
.toggle-label:hover .toggle-text { color: var(--text-main); }
@media (min-width: 640px) { .toggle-text { display: block; } }

/* Layout */
.main-layout {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 2rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
}
@media (min-width: 768px) { .main-layout { flex-direction: row; } }

/* Sidebar */
.sidebar {
  width: 100%;
  flex-shrink: 0;
}
@media (min-width: 768px) { .sidebar { width: 16rem; } }
.sidebar-sticky {
  position: sticky;
  top: 6rem;
}
.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 1rem 0;
}
.sidebar-title.mt { margin-top: 2rem; }

.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.category-item {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.category-item.active {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
}
.category-item:not(.active):hover {
  background-color: var(--border);
}

.sort-select {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border-focus);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
  appearance: auto;
}
.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

/* Content Area */
.content-area {
  flex: 1;
}
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}
.content-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.content-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}
.content-subtitle span {
  font-weight: 600;
  color: var(--text-main);
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
}
@media (min-width: 640px) { .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Product Card */
.product-card {
  background-color: var(--surface);
  border-radius: 1rem;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 0 0 2px var(--primary), 0 16px 32px -8px rgba(10, 103, 219, 0.2);
}
.card-image-wrap {
  height: 12rem;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1rem;
}
.card-icon {
  font-size: 3rem;
  color: var(--text-light);
}
.card-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-in-stock {
  background-color: var(--success-bg);
  color: var(--success-text);
  box-shadow: inset 0 0 0 1px var(--success-border);
}
.badge-in-stock .dot {
  width: 0.375rem; height: 0.375rem;
  border-radius: 50%;
  background-color: var(--success-dot);
}
.badge-out-stock {
  background-color: var(--error-bg);
  color: var(--error-text);
  box-shadow: inset 0 0 0 1px var(--error-border);
}
.badge-out-stock .dot {
  width: 0.375rem; height: 0.375rem;
  border-radius: 50%;
  background-color: var(--error-dot);
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.card-category {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
}
.card-title {
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.25;
  margin: 0 0 0.5rem 0;
}
.card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;  
  overflow: hidden;
}
.card-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}
.card-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--bg-color);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
}
.card-link:hover {
  background-color: var(--primary);
  color: white;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
  text-align: center;
}
.empty-icon-wrap {
  background-color: #f1f5f9;
  padding: 1.5rem;
  border-radius: 50%;
  margin-bottom: 1rem;
}
.empty-icon-wrap i {
  font-size: 2.5rem;
  color: var(--text-light);
}
.empty-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.empty-desc {
  color: var(--text-muted);
  margin: 0.5rem 0 0 0;
  max-width: 24rem;
}
.empty-reset {
  margin-top: 1.5rem;
  color: var(--primary);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}
.empty-reset:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Error State Additions */
.empty-state-full {
  grid-column: 1 / -1;
}
.error-icon {
  font-size: 3rem;
  color: var(--error-dot);
  margin-bottom: 1rem;
}

/* Footer */
.footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: auto;
  text-align: center;
}
.footer-icon {
  font-size: 1.5rem;
  color: var(--border-focus);
  margin-bottom: 0.5rem;
}
.footer-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-container {
  background-color: var(--surface);
  border-radius: 1.5rem;
  width: 100%;
  max-width: 56rem;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.hidden .modal-container {
  transform: scale(0.95);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--bg-color);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s;
  z-index: 10;
}
.modal-close:hover {
  background-color: var(--error-bg);
  color: var(--error-text);
}
.modal-content-wrapper {
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .modal-content-wrapper {
    flex-direction: row;
  }
}
.modal-image-col {
  width: 100%;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 20rem;
}
@media (min-width: 768px) {
  .modal-image-col {
    width: 45%;
    min-height: auto;
  }
}
.modal-image-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-image-wrap img {
  max-width: 100%;
  max-height: 24rem;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}
.modal-image-wrap i {
  font-size: 6rem;
  color: var(--text-light);
}
.modal-details-col {
  width: 100%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .modal-details-col {
    width: 55%;
    padding: 3rem;
  }
}
.modal-category {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: block;
}
.modal-title {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin: 0 0 1rem 0;
}
.modal-stock {
  margin-bottom: 1.5rem;
}
.modal-price-wrap {
  margin-bottom: 1.5rem;
}
.modal-price {
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--text-main);
}
.modal-divider {
  height: 1px;
  background-color: var(--border);
  margin: 1.5rem 0;
}
.modal-desc-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.5rem 0;
}
.modal-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 2rem 0;
}
.modal-actions {
  margin-top: auto;
}
.modal-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background-color: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 0.75rem;
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}
.modal-btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.3);
}

/* Update Product Card to be clickable */
.product-card {
  cursor: pointer;
}
.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

/* Carousel Styles */
.carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.carousel-slides {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease-in-out;
}
.carousel-slides img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
}
.modal-image-wrap .carousel-slides img {
  object-fit: contain;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s;
  z-index: 2;
  opacity: 0;
}
.card-image-wrap:hover .carousel-btn,
.modal-image-col:hover .carousel-btn {
  opacity: 1;
}
.carousel-btn:hover {
  background: var(--primary);
  color: white;
}
.carousel-btn.prev { left: 0.5rem; }
.carousel-btn.next { right: 0.5rem; }
.carousel-dots {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.25rem;
  z-index: 2;
}
.carousel-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: all 0.2s;
}
.carousel-dot.active {
  background: var(--primary);
  transform: scale(1.2);
}

/* CSP Helper Classes */
.body-no-scroll { overflow: hidden !important; }
.modal-single-img { max-width: 100%; max-height: 24rem; object-fit: contain; }
.modal-badge { position: static !important; }

.slide-pos-0 { transform: translateX(0); }
.slide-pos-1 { transform: translateX(-100%); }
.slide-pos-2 { transform: translateX(-200%); }
.slide-pos-3 { transform: translateX(-300%); }
.slide-pos-4 { transform: translateX(-400%); }
.slide-pos-5 { transform: translateX(-500%); }
.slide-pos-6 { transform: translateX(-600%); }
.slide-pos-7 { transform: translateX(-700%); }
.slide-pos-8 { transform: translateX(-800%); }
.slide-pos-9 { transform: translateX(-900%); }

