:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --shadow-sm: 0 2px 8px rgba(79, 70, 229, 0.1);
  --shadow-md: 0 8px 24px rgba(79, 70, 229, 0.15);
  --shadow-lg: 0 12px 32px rgba(79, 70, 229, 0.2);
  --shadow-3d: 0 20px 60px rgba(79, 70, 229, 0.3), 0 8px 16px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f4f8;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  color: var(--text);
  min-height: 100vh;
}

/* ---------------- HEADER ---------------- */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  height: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease;
}

.brand img:hover {
  transform: scale(1.05) rotate(2deg);
}

.brand span {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------------- CONTAINER ---------------- */
.container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.section-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  position: relative;
  padding-left: 12px;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
  border-radius: 2px;
}

/* ---------------- CATEGORY SEARCH ---------------- */
.cat-search {
  background: white;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.cat-search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(79, 70, 229, 0.1);
  transform: translateY(-2px);
}

.cat-search input {
  border: none;
  outline: none;
  background: none;
  width: 100%;
  font-size: 15px;
  color: var(--text);
}

.cat-search input::placeholder {
  color: var(--muted);
}

/* ---------------- CATEGORIES GRID ---------------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.cat-card {
  background: var(--card);
  border-radius: 10px;
  padding: 20px 12px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.cat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cat-card:hover::before {
  opacity: 1;
}

.cat-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-3d);
  border-color: var(--primary-light);
}

.cat-card:active {
  transform: translateY(-4px) scale(0.98);
}

.cat-card img {
  width: 90px;
  height: 90px;
  border-radius: 10%;
  object-fit: fill;
  border: 2px solid var(--primary);
  margin-bottom: 12px;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.2);
  transition: transform 0.3s ease;
}

.cat-card:hover img {
  transform: scale(1.1) rotate(3deg);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.3);
}

.cat-card h3 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

.no-cat {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 30px;
  color: var(--muted);
  font-size: 16px;
}

/* ---------------- MODAL ---------------- */
.modal {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 2000;
  display: none;
  flex-direction: column;
}

.slide-in {
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.modal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
  box-shadow: var(--shadow-sm);
}

.back-btn {
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.back-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
}

/* ---------------- SEARCH ---------------- */
.search-container {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
}

.search-box {
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.search-box:focus-within {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-box input {
  border: none;
  outline: none;
  background: none;
  width: 100%;
  font-size: 15px;
}

/* ---------------- PRODUCTS - 3 PER ROW ---------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  perspective: 1000px;
}

.prod-card {
  background: linear-gradient(145deg, #ffffff 0%, #fafbff 100%);
  border-radius: 20px;
  border: 2px solid rgba(79, 70, 229, 0.08);
  box-shadow: 
    0 8px 16px rgba(79, 70, 229, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  transform-style: preserve-3d;
}

.prod-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 1;
}

.prod-card:active::before {
  opacity: 1;
}

.prod-card:active {
  transform: translateY(-12px) rotateX(5deg) scale(1.02);
  box-shadow: 
    0 20px 40px rgba(79, 70, 229, 0.25),
    0 10px 20px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  border-color: rgba(99, 102, 241, 0.3);
}

.prod-img {
  width: 100%;
  aspect-ratio: 1/1;
  background: linear-gradient(145deg, #f8f9ff 0%, #f1f3f9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin: 8px;
  box-shadow: 
    0 4px 12px rgba(79, 70, 229, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.1),
    inset 0 -2px 6px rgba(79, 70, 229, 0.05);
  transition: all 0.4s ease;
}

.prod-card:active .prod-img {
  box-shadow: 
    0 8px 20px rgba(79, 70, 229, 0.25),
    0 4px 10px rgba(0, 0, 0, 0.15),
    inset 0 -3px 8px rgba(79, 70, 229, 0.08);
  transform: scale(1.05);
}

.prod-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.08), transparent 70%);
  border-radius: 18px;
}

.prod-img img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: fill;
  opacity: 0;
  transition: all 0.4s ease;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.prod-card:active .prod-img img {
  transform: scale(1.08) translateZ(20px);
}

.loaded img {
  opacity: 1;
}

.prod-info {
  padding: 12px 12px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.95) 100%);
  position: relative;
  transform: translateZ(10px);
}

.prod-info::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
}

.prod-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  height: 1.5em;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  letter-spacing: 0.2px;
}

.prod-price {
  font-size: 16px;
  font-weight: 900;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(79, 70, 229, 0.1);
  filter: drop-shadow(0 1px 2px rgba(79, 70, 229, 0.2));
  position: relative;
  display: inline-block;
}

.prod-price::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #4f46e5, #7c3aed, #ec4899);
  border-radius: 2px;
  opacity: 0.3;
}

.prod-meta {
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 5px 8px;
  border-radius: 8px;
  width: fit-content;
  margin-bottom: 4px;
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(79, 70, 229, 0.08);
  transition: all 0.3s ease;
}

.prod-card:active .prod-meta {
  transform: translateZ(15px);
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.prod-meta i {
  font-size: 12px;
}

.prod-meta.location i {
  color: #ef4444;
  filter: drop-shadow(0 1px 2px rgba(239, 68, 68, 0.3));
  animation: locationPulse 2s ease-in-out infinite;
}

.prod-meta.stock {
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  border-color: rgba(34, 197, 94, 0.2);
  color: #15803d;
}

.stock-dot {
  color: #22c55e;
  font-size: 11px;
  filter: drop-shadow(0 0 3px rgba(34, 197, 94, 0.6));
  animation: stockPulse 2s ease-in-out infinite;
}

@keyframes stockPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.9);
  }
}

@keyframes locationPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ---------------- LOADER ---------------- */
.skeleton {
  background: linear-gradient(90deg, #e5e7eb 25%, #f1f5f9 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 12px;
}

@keyframes shimmer {
  from {
    background-position: 200%;
  }
  to {
    background-position: -200%;
  }
}

.hidden {
  display: none;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 16px;
  grid-column: 1/-1;
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1024px) {
  .cat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .product-grid {
    gap: 10px;
    padding: 12px;
  }
  
  .prod-img {
    margin: 6px;
    padding: 10px;
  }
  
  .prod-name {
    font-size: 10px;
  }
  
  .prod-price {
    font-size: 14px;
  }
  
  .prod-meta {
    font-size: 8px;
    padding: 4px 7px;
  }
}

@media (max-width: 640px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .container {
    padding: 12px;
  }
  
  header {
    padding: 12px 16px;
  }
  
  .brand span {
    font-size: 18px;
  }
  
  .brand img {
    height: 36px;
  }
}

@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
  }
  
  .prod-card {
    border-radius: 16px;
  }
  
  .prod-img {
    padding: 8px;
    margin: 6px;
    border-radius: 14px;
  }
  
  .prod-info {
    padding: 8px 8px 10px;
  }
  
  .prod-name {
    font-size: 9px;
    margin-bottom: 5px;
  }
  
  .prod-price {
    font-size: 13px;
    margin-bottom: 6px;
  }
  
  .prod-meta {
    font-size: 7.5px;
    padding: 4px 6px;
  }
  
  .prod-meta i {
    font-size: 8px;
  }
}

@media (max-width: 360px) {
  .product-grid {
    gap: 6px;
    padding: 8px;
  }
  
  .prod-card {
    border-radius: 14px;
  }
  
  .prod-img {
    padding: 6px;
    margin: 5px;
    border-radius: 12px;
  }
  
  .prod-info {
    padding: 6px 6px 8px;
  }
  
  .prod-name {
    font-size: 8px;
    margin-bottom: 4px;
  }
  
  .prod-price {
    font-size: 12px;
    margin-bottom: 5px;
  }
  
  .prod-meta {
    font-size: 7px;
    padding: 3px 5px;
  }
  
  .prod-meta i {
    font-size: 7px;
  }
}
