/* =========================================================
   VirtualFit — Warm Glassmorphism Try-On UI
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --vf-bg: #2c231a;
  --vf-bg-warm: #3a3028;
  --vf-glass: rgba(180, 160, 140, 0.12);
  --vf-glass-strong: rgba(180, 160, 140, 0.2);
  --vf-glass-hover: rgba(200, 180, 160, 0.18);
  --vf-border: rgba(255, 255, 255, 0.1);
  --vf-border-strong: rgba(255, 255, 255, 0.18);
  --vf-text: #ffffff;
  --vf-text-muted: rgba(255, 255, 255, 0.6);
  --vf-text-soft: rgba(255, 255, 255, 0.45);
  --vf-accent: #c4a882;
  --vf-accent-glow: rgba(196, 168, 130, 0.3);
  --vf-radius: 24px;
  --vf-radius-sm: 14px;
  --vf-blur: 30px;
}

/* ---- Page ---- */
.tryon-page {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding: 1.5rem;
  color: var(--vf-text);
  background:
    radial-gradient(ellipse at 20% 80%, rgba(139, 115, 85, 0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(120, 100, 75, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(80, 65, 45, 0.15) 0%, transparent 70%),
    linear-gradient(180deg, var(--vf-bg) 0%, var(--vf-bg-warm) 50%, var(--vf-bg) 100%);
  animation: fadeIn 0.6s ease-out;
}

/* ---- Category Tabs ---- */
.tryon-category-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 1.5rem;
  background: var(--vf-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--vf-border);
  border-radius: 40px;
  padding: 5px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.cat-tab {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--vf-text-muted);
  background: transparent;
  border: none;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.cat-tab:hover {
  color: var(--vf-text);
  background: rgba(255, 255, 255, 0.06);
}

.cat-tab.active {
  color: var(--vf-text);
  background: var(--vf-glass-strong);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---- Glass Panel ---- */
.tryon-glass-panel {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--vf-glass);
  backdrop-filter: blur(var(--vf-blur));
  -webkit-backdrop-filter: blur(var(--vf-blur));
  border: 1px solid var(--vf-border);
  border-radius: var(--vf-radius);
  padding: 1rem;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---- Toolbar ---- */
.tryon-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.virtualfit-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--vf-glass-strong);
  border: 1px solid var(--vf-border);
  border-radius: 30px;
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--vf-text);
  letter-spacing: 0.3px;
}

.vf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vf-accent);
  box-shadow: 0 0 6px var(--vf-accent-glow);
  display: inline-block;
}

.toolbar-views {
  display: flex;
  gap: 2px;
  background: var(--vf-glass);
  border: 1px solid var(--vf-border);
  border-radius: 10px;
  padding: 3px;
}

.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--vf-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-btn:hover { color: var(--vf-text); }
.view-btn.active {
  background: var(--vf-glass-strong);
  color: var(--vf-text);
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--vf-glass-strong);
  border: 1px solid var(--vf-border);
  border-radius: 30px;
  padding: 7px 18px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--vf-text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.toolbar-btn:hover {
  background: var(--vf-glass-hover);
  border-color: var(--vf-border-strong);
  text-decoration: none;
  color: var(--vf-text);
}

.toolbar-btn-primary {
  background: rgba(196, 168, 130, 0.2);
  border-color: rgba(196, 168, 130, 0.3);
}

.toolbar-btn-primary:hover {
  background: rgba(196, 168, 130, 0.3);
}

.toolbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--vf-glass);
  border: 1px solid var(--vf-border);
  border-radius: 50%;
  color: var(--vf-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-icon-btn:hover {
  background: var(--vf-glass-strong);
  color: var(--vf-text);
}

/* ---- Main Content Layout ---- */
.tryon-container {
  display: flex;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- Left Side: Camera ---- */
.tryon-left {
  flex: 0 0 65%;
  display: flex;
  flex-direction: column;
}

/* ---- Right Side: Products ---- */
.tryon-right {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  background: var(--vf-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--vf-border);
  border-radius: var(--vf-radius);
  padding: 1rem;
  max-height: calc(100vh - 4rem);
  overflow: hidden;
}

/* ---- Product Grid ---- */
.tryon-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--vf-accent) rgba(0,0,0,0.2);
}

.tryon-product-grid::-webkit-scrollbar {
  width: 6px;
}
.tryon-product-grid::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}
.tryon-product-grid::-webkit-scrollbar-thumb {
  background: var(--vf-accent);
  border-radius: 10px;
}

/* ---- Product Cards ---- */
.product-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--vf-border);
  border-radius: var(--vf-radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.product-card:hover {
  background: var(--vf-glass-hover);
  border-color: var(--vf-border-strong);
  transform: translateY(-2px);
}

.card-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/5;
  background: rgba(0,0,0,0.2);
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discount-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #e11d48;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
}

.card-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-info h4 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--vf-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rating {
  color: #fbbf24;
  font-size: 0.75rem;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.price-row .price {
  color: var(--vf-accent);
  font-weight: 700;
  font-size: 0.95rem;
}

.price-row .old-price {
  color: var(--vf-text-muted);
  font-size: 0.75rem;
  text-decoration: line-through;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.btn-tryon, .btn-cart {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tryon {
  background: var(--vf-accent);
  color: #1a1510;
}
.btn-tryon:hover {
  background: #d4b892;
}

.btn-cart {
  background: rgba(255,255,255,0.1);
  color: var(--vf-text);
  border: 1px solid var(--vf-border);
}
.btn-cart:hover {
  background: rgba(255,255,255,0.2);
}

/* ---- Camera ---- */
.tryon-camera-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tryon-camera {
  position: relative;
  flex: 1;
  background: #1a1510;
  border-radius: var(--vf-radius-sm);
  overflow: hidden;
  aspect-ratio: 4/3;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

#tryonCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

/* ---- Camera Overlay ---- */
.camera-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 16, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.overlay-content {
  text-align: center;
  padding: 2rem;
}

.overlay-silhouette {
  margin-bottom: 1rem;
  opacity: 0.6;
}

.overlay-hint {
  color: var(--vf-text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem 0;
}

.btn-start-camera {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--vf-accent);
  color: #1a1510;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 25px var(--vf-accent-glow);
  transition: all 0.3s ease;
}

.btn-start-camera:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 35px rgba(196, 168, 130, 0.5);
  background: #d4b892;
}

/* ---- Actions ---- */
.tryon-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0 0 0;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--vf-glass-strong);
  border: 1px solid var(--vf-border);
  color: var(--vf-text);
  padding: 8px 18px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
}

.action-btn:hover {
  background: var(--vf-glass-hover);
  border-color: var(--vf-border-strong);
  transform: translateY(-1px);
}

.action-btn-outline {
  background: transparent;
}

.action-btn-danger {
  background: rgba(200, 60, 60, 0.2);
  border-color: rgba(200, 60, 60, 0.3);
  color: #f0a0a0;
}

.action-btn-danger:hover {
  background: rgba(200, 60, 60, 0.3);
}

/* ---- Product Detail Bar ---- */
.tryon-product-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(180, 150, 110, 0.15), rgba(160, 130, 100, 0.08));
  border: 1px solid var(--vf-border);
  border-radius: 16px;
  animation: slideUp 0.3s ease-out;
}

.detail-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.detail-left h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--vf-text);
}

.detail-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--vf-accent);
}

.detail-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.detail-meta {
  font-size: 0.8rem;
  color: var(--vf-text-muted);
}

.detail-meta strong {
  color: var(--vf-text);
  font-weight: 600;
  margin-left: 4px;
}

.detail-edit-btn {
  background: var(--vf-glass-strong);
  border: 1px solid var(--vf-border);
  color: var(--vf-text);
  padding: 8px 22px;
  border-radius: 30px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.detail-edit-btn:hover {
  background: var(--vf-accent);
  color: #1a1510;
  border-color: var(--vf-accent);
}

/* ---- Status ---- */
.tryon-status {
  max-width: 1200px;
  margin: 0.75rem auto 0 auto;
  background: var(--vf-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--vf-border);
  border-left: 3px solid var(--vf-accent);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--vf-text-muted);
  text-align: center;
}

/* ---- Loading ---- */
.tryon-loading {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 16, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 30;
  color: var(--vf-text);
  border-radius: var(--vf-radius-sm);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--vf-accent);
  border-right-color: rgba(196, 168, 130, 0.5);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 14px;
}

/* ---- Toast ---- */
.tryon-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--vf-glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--vf-border);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: var(--vf-text);
  font-weight: 500;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.tryon-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Screenshot Modal ---- */
.screenshot-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1rem;
}

.screenshot-content {
  background: var(--vf-glass-strong);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--vf-border);
  width: 100%;
  max-width: 500px;
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.35s ease-out;
}

.screenshot-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
}

.screenshot-content img {
  max-width: 100%;
  border-radius: var(--vf-radius-sm);
  margin-bottom: 1.5rem;
}

.screenshot-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .tryon-container {
    flex-direction: column;
  }

  .tryon-left, .tryon-right {
    flex: 0 0 100%;
  }
  
  .tryon-right {
    max-height: none;
    overflow: visible;
  }
  
  .tryon-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 768px) {
  .tryon-page { padding: 0.75rem; }

  .tryon-glass-panel { padding: 0.75rem; }

  .tryon-toolbar {
    gap: 8px;
  }

  .toolbar-btn { font-size: 0.72rem; padding: 6px 12px; }

  .cat-tab { padding: 8px 16px; font-size: 0.78rem; }

  .tryon-camera { aspect-ratio: 3/4; }

  .tryon-side-products {
    width: 100%;
  }

  .tryon-product-detail {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .detail-left, .detail-right {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .tryon-category-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
    justify-content: flex-start;
  }
  .tryon-category-tabs::-webkit-scrollbar { display: none; }

  .toolbar-views { display: none; }

  .tryon-side-products .product-card {
    min-width: 110px;
  }

  .side-nav-btn { width: 38px; height: 38px; }
}

/* ---- Utility: hide product section label (legacy) ---- */
.tryon-product-section { display: none; }
