/* ==========================================================================
   VIRTUAL SUPERMARKET 360° - CORE CSS STYLESHEET
   Design Language: Glassmorphic Minimalist, Costco Red Accents, Apple UI Polish
   ========================================================================== */

:root {
  /* Color Tokens */
  --primary-red: #E31837; /* Costco Red */
  --primary-red-hover: #c8132e;
  --fresh-green: #10B981;
  --accent-gold: #F59E0B;
  --accent-blue: #0EA5E9;
  --accent-purple: #8B5CF6;
  
  --bg-dark: #0f172a;
  --bg-light: #f8fafc;
  
  /* Glassmorphism System */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25), 0 0 15px rgba(255, 255, 255, 0.5) inset;
  --glass-blur: blur(16px);
  
  --dark-glass-bg: rgba(15, 23, 42, 0.75);
  --dark-glass-border: rgba(255, 255, 255, 0.12);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  /* Radius & Transitions */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.2s var(--ease-smooth);
  --transition-normal: 0.35s var(--ease-smooth);
  --transition-slow: 0.6s var(--ease-smooth);
}

/* High Contrast Accessibility Mode */
body.high-contrast {
  --glass-bg: rgba(255, 255, 255, 0.98);
  --glass-border: #000000;
  --text-main: #000000;
  --text-muted: #222222;
  --primary-red: #d00000;
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-drag: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 360 Canvas Container */
#viewport-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
}

#canvas360 {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  position: fixed;
}

#canvas360:active {
  cursor: grabbing;
}

/* Hotspot Overlay Layer */
#hotspots-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

/* Floating Glass Navbar Header */
.top-navbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: calc(100% - 32px);
  max-width: 1280px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  transition: transform var(--transition-normal);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.brand-logo i {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-red), #ff4d6d);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(227, 24, 55, 0.4);
}

.brand-title span {
  color: var(--primary-red);
}

.badge-360 {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(227, 24, 55, 0.1);
  color: var(--primary-red);
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 700;
}

/* Global Search Bar */
.search-container {
  position: relative;
  width: 380px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-full);
  outline: none;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px rgba(227, 24, 55, 0.15);
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 380px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 16px 32px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.08);
  display: none;
  z-index: 100;
  padding: 8px 0;
}

.search-results-dropdown.active {
  display: block;
  animation: fadeInDown 0.2s var(--ease-smooth);
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-item:hover {
  background: rgba(227, 24, 55, 0.05);
}

.search-item img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
}

.search-item-info h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.search-item-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Nav Shortcuts */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-glass {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-glass:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-glass.btn-ai {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(14, 165, 233, 0.15));
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--accent-purple);
}

.btn-glass.btn-ai:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(14, 165, 233, 0.25));
}

/* Aisle Breadcrumbs Bar (Top Left below Nav) */
.aisle-breadcrumbs-bar {
  position: absolute;
  top: 86px;
  left: 24px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.aisle-breadcrumbs-bar i {
  color: var(--primary-red);
}

.aisle-badge {
  padding: 2px 8px;
  background: var(--primary-red);
  color: white;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
}

/* Department Quick-Jump Toolbar (Bottom Center) */
.dept-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.dept-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dept-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.5);
}

.dept-tab.active {
  background: #ffffff;
  color: var(--primary-red);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Floating Cart Badge Button (Bottom Right) */
.cart-floating-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--primary-red), #ff2a4b);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 10px 25px rgba(227, 24, 55, 0.45);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cart-floating-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 30px rgba(227, 24, 55, 0.55);
}

.cart-floating-btn .cart-count-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: white;
  color: var(--primary-red);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 800;
}

/* Mini-map Widget (Bottom Left) */
.minimap-widget {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 45;
  width: 180px;
  height: 180px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow);
  padding: 10px;
  overflow: hidden;
  transition: transform var(--transition-fast);
}

.minimap-widget:hover {
  transform: scale(1.05);
}

.minimap-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.minimap-canvas-wrapper {
  position: relative;
  width: 100%;
  height: calc(100% - 20px);
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}

#minimap-svg {
  width: 100%;
  height: 100%;
}

.map-node {
  cursor: pointer;
  transition: transform 0.2s var(--ease-out-back);
}

.map-node:hover {
  transform: scale(1.3);
}

/* 3D Dynamic Hotspot Pins & Polygon Overlays */
.hotspot-pin {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  z-index: 20;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

/* Ground Aisle Arrow Hotspot */
.aisle-arrow-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.arrow-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 2px solid white;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 8px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-red);
  font-size: 1.3rem;
  animation: pulseGroundArrow 2s infinite ease-in-out;
}

@keyframes pulseGroundArrow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 255, 255, 0.8); }
  50% { transform: scale(1.15); box-shadow: 0 0 35px rgba(227, 24, 55, 0.9); }
}

.arrow-label {
  padding: 4px 12px;
  background: rgba(15, 23, 42, 0.85);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Shelf Product Polygon & Quick Card Hover */
.product-spot {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
}

.spot-pulse {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(227, 24, 55, 0.4);
  border: 2px solid #ffffff;
  box-shadow: 0 0 15px rgba(227, 24, 55, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
  animation: spotGlow 1.8s infinite;
}

@keyframes spotGlow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 25px rgba(255, 255, 255, 1); }
}

.product-spot:hover .spot-pulse {
  background: var(--primary-red);
  transform: scale(1.3);
}

/* Quick Hover Preview Card */
.quick-card {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  width: 220px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 30;
}

.product-spot:hover .quick-card {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.quick-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.quick-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 4px;
}

.quick-card-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.quick-card-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-red);
}

.quick-card-discount {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--fresh-green);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Rich Product Detail Side Panel Drawer */
.product-panel-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 440px;
  height: 100vh;
  z-index: 100;
  background: #ffffff;
  box-shadow: -10px 0 40px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.product-panel-drawer.open {
  transform: translateX(0);
}

.panel-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
}

.btn-close-panel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-close-panel:hover {
  background: #e2e8f0;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.panel-product-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.panel-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.panel-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 8px;
}

.panel-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--accent-gold);
  margin-bottom: 16px;
}

.panel-price-box {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: var(--radius-md);
}

.panel-current-price {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary-red);
}

.panel-old-price {
  font-size: 1rem;
  text-decoration: line-through;
  color: var(--text-muted);
}

.panel-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 16px 0 8px;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.nutrition-card {
  background: #f1f5f9;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.nutrition-value {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
}

.nutrition-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.panel-footer {
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 12px;
  background: #ffffff;
}

.quantity-picker {
  display: flex;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.quantity-btn {
  width: 36px;
  height: 40px;
  border: none;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
}

.quantity-value {
  width: 36px;
  text-align: center;
  font-weight: 700;
}

.btn-add-to-cart {
  flex: 1;
  padding: 12px;
  background: var(--primary-red);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-add-to-cart:hover {
  background: var(--primary-red-hover);
}

/* Persistent Cart Side Panel & Checkout Overlay */
.cart-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  z-index: 110;
  background: #ffffff;
  box-shadow: -10px 0 40px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.cart-item-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.cart-item-card img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}

.cart-item-details {
  flex: 1;
}

.cart-item-title {
  font-size: 0.88rem;
  font-weight: 700;
}

.cart-item-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-red);
}

/* Flying Product Parabolic Animation Particle */
.flying-particle {
  position: absolute;
  z-index: 999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 25px rgba(227, 24, 55, 0.6);
  pointer-events: none;
  transition: transform 0.75s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.75s ease;
}

/* AI Assistant Drawer */
.ai-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: 380px;
  height: 100vh;
  z-index: 105;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: var(--glass-blur);
  box-shadow: 10px 0 40px rgba(0,0,0,0.25);
  transform: translateX(-100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.ai-drawer.open {
  transform: translateX(0);
}

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  max-width: 85%;
  font-size: 0.88rem;
  line-height: 1.4;
}

.chat-bubble.bot {
  background: #f1f5f9;
  align-self: flex-start;
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: var(--primary-red);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Search Highlight Beacon Rings in 360 */
.search-beacon {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--primary-red);
  background: rgba(227, 24, 55, 0.2);
  animation: beaconPing 1.5s infinite ease-out;
  pointer-events: none;
}

@keyframes beaconPing {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

/* Animations */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive Layout */
@media (max-width: 768px) {
  .top-navbar {
    width: calc(100% - 16px);
    padding: 8px 12px;
  }
  .search-container {
    width: 180px;
  }
  .product-panel-drawer, .cart-drawer {
    width: 100vw;
  }
  .minimap-widget {
    width: 130px;
    height: 130px;
  }
  .dept-toolbar {
    overflow-x: auto;
    max-width: 90vw;
  }
}
