:root {
  --bg-primary: #F8FAFC; /* Off-White for main background, Blurred Backgrounds */
  --bg-accent: #E2E8F0; /* Lighter Slate Gray variant for gradient */
  --bg: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-accent) 100%);
  --surface: rgba(248, 250, 252, 0.5); /* Off-White with transparency for glassmorphism */
  --text: #1E293B; /* Darker Slate for readability */
  --muted: #64748B; /* Slate Gray for secondary text, Frosted Borders */
  --primary: #007BFF; /* Electric Blue for main branding, Glassmorphic Nav, Buttons */
  --primary-hover: #0056B3; /* Darker Electric Blue for hover */
  --danger: #FF2E63; /* Neon Coral for highlights, Glowing Badges */
  --danger-hover: #E62957; /* Darker Neon Coral for hover */
  --accent: #FF6200; /* Sunset Orange for CTAs, Frosted CTAs, Banners */
  --accent-hover: #E55A00; /* Darker Sunset Orange for hover */
  --border: rgba(100, 116, 139, 0.5); /* Semi-transparent Slate Gray for borders */
  --shadow: 0 6px 20px rgba(2, 6, 23, 0.12); /* Softer shadow for depth */
  --glow: 0 0 10px rgba(255, 46, 99, 0.5); /* Neon Coral glow for highlights */
  --radius: 16px; /* Increased for smoother, modern look */
  --blur: blur(10px); /* Glassmorphic blur effect */
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
  background: var(--bg);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

/* Header / Nav */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 20px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.header .flex {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.header a {
  text-decoration: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s ease;
  white-space: nowrap;
}
.header a:hover { background: rgba(248, 250, 252, 0.3); }

/* Navigation Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Search Bar */
#search {
  flex: 1 1 auto;
  min-width: 200px;
  max-width: 100%;
}

/* Cart Icon (Font Awesome) */
.cart-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; /* Fixed size for icon container */
  height: 40px;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.cart-icon i {
  font-size: 24px; /* Icon size */
  color: var(--text); /* Matches header text color */
}
.cart-icon:hover {
  background: rgba(248, 250, 252, 0.3); /* Matches header link hover */
}

.cart-icon {
  position: relative;
  display: inline-block;
}

.cart-icon .cart-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--primary);     /* Your perfect blue */
  color: white;
  font-size: 11px;
  font-weight: bold;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
  text-align: center;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(0, 86, 179, 0.5);
  z-index: 10;
  transition: all 0.2s ease;
}


/* Auth Links */
#authLinks {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Logo */
.header > .flex > img {
  flex-shrink: 0;
  height: 40px;
}

/* Search Button */
#doSearch {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Grid & Card */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 16px; /* Add vertical spacing between stacked cards */
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.16);
}
.card img {
  width: 100%;
  aspect-ratio: 4/3;
  height: auto;
  object-fit: cover;
  background: #ffffff;
}
.card-body { 
  padding: 16px; 
}

.card-title { 
  font-weight: 700; 
  margin: 0 0 8px; 
}

.card-meta {
  color: var(--muted); 
  font-size: 0.94rem; 
}

#addCartBtn {
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: var(--blur);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: rgba(248, 250, 252, 0.3); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary);
  backdrop-filter: var(--blur);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.3);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger {
  background: var(--danger);
  backdrop-filter: var(--blur);
  color: #fff;
  border-color: var(--danger);
  box-shadow: var(--glow);
}
.btn.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn.accent {
  background: var(--accent);
  backdrop-filter: var(--blur);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(255, 98, 0, 0.3);
}
.btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

a {
  text-decoration: none;
  color: black;
}

/* Inputs */
.input, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}



/* Responsive adjustments */
/* Large screens - default layout works well */
@media (min-width: 1200px) {
  .header .flex {
    gap: 16px;
  }
  #search {
    flex: 1 1 400px;
    max-width: 600px;
  }
}

/* Medium screens (tablets) */
@media (max-width: 992px) {
  .header {
    padding: 12px 16px;
  }
  .header .flex {
    gap: 10px;
  }
  #search {
    flex: 1 1 300px;
    min-width: 200px;
  }
  .nav-links {
    gap: 6px;
  }
  .nav-links a {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
}

/* Small screens (small tablets, large phones) */
@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
  }
  .header .flex {
    gap: 8px;
  }
  .header > .flex > img {
    min-height: 32px;
    height: 32px;
    margin-right: 8px;
  }
  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }
  .nav-links a {
    padding: 6px 8px;
    font-size: 0.85rem;
  }
  /* Hide only the search button on mobile - users can press Enter to search */
  #search {
    order: 1;
    flex: 1 1 calc(100% - 120px);
    min-width: 150px;
  }
  #doSearch {
    display: none;
  }
  .cart-icon,
  #authLinks {
    order: 0;
    flex-shrink: 0;
  }
}

/* Extra small screens (phones) */
@media (max-width: 600px) {
  .header {
    padding: 8px 10px;
  }
  .header .flex {
    gap: 8px;
  }
  .header > .flex > img {
    min-height: 28px;
    height: 28px;
    margin-right: 6px;
  }
  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    gap: 4px;
  }
  .nav-links a {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  /* Hide only the search button on mobile - users can press Enter to search */
  #search {
    order: 1;
    flex: 1 1 calc(100% - 120px);
    min-width: 150px;
  }
  #doSearch {
    display: none;
  }
  .cart-icon {
    width: 36px;
    height: 36px;
  }
  .cart-icon i {
    font-size: 20px;
  }
  #authLinks {
    order: 0;
    flex-shrink: 0;
  }
  #authLinks a {
    padding: 6px 8px;
  }
}

/* Layout helpers */
.flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--danger);
  backdrop-filter: var(--blur);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--glow);
}
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table tr:hover td { background: rgba(248, 250, 252, 0.3); }

/* Slider */
.slider {
  position: relative;
  margin: 20px 0;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.slider-track { display: flex; width: 100%; transition: transform 0.4s ease; }
.slide { min-width: 100%; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.slide img { width: 100%; height: 300px; object-fit: contain; display: block; }
.slider-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--primary);
  backdrop-filter: var(--blur);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.3);
}
.slider-nav.prev { left: 12px; }
.slider-nav.next { right: 12px; }

/* Theme picker panel */
.theme-picker {
  position: fixed;
  right: 20px;
  top: 72px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: var(--blur);
  color: #fff;
  box-shadow: var(--shadow);
  max-width: 420px;
}
.theme-title { font-weight: 700; text-align: center; letter-spacing: 0.08em; }
.theme-bar {
  position: relative;
  height: 56px;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--surface);
  backdrop-filter: var(--blur);
}
.theme-color { width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; }
.theme-swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.swatch {
  height: 56px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: var(--blur);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.theme-actions { display: flex; justify-content: center; gap: 12px; }
.theme-picker.hidden { display: none; }

/* Profile preview menu (hamburger) */
.profile-menu {
  position: fixed;
  left: 20px;
  top: 72px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: var(--blur);
  color: #fff;
  box-shadow: var(--shadow);
  min-width: 240px;
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.profile-menu.open { opacity: 1; transform: translateX(0); pointer-events: auto; }
.profile-title { font-weight: 700; letter-spacing: 0.08em; }
.profile-header { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.profile-name-row { display: flex; align-items: center; gap: 8px; }
.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--muted);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
}
.profile-info { color: #CBD5E1; text-align: center; }
.profile-edit { color: #CBD5E1; text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.profile-edit:hover { background: rgba(255, 255, 255, 0.1); }
.profile-divider { height: 1px; background: var(--border); margin: 6px 0 4px; }
.profile-links, .profile-actions { display: flex; flex-direction: column; gap: 8px; }

/* Non-blocking toast for small status messages */
.theme-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: var(--blur);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
}
.theme-toast.show { opacity: 1; transform: translateY(0); }

#promoSlider {
  width: 100%;
  height: 300px;
}
/* Plain link styling for profile menu */
.profile-menu a { color: #CBD5E1; text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.profile-menu a:hover { text-decoration: underline; }

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(10px)) {
  .header, .card, .btn, .input, select, .slider, .theme-picker, .profile-menu, .theme-toast, .swatch, .theme-bar {
    background: var(--surface) !important;
  }
}