/* ---------- Layout riêng cho hero của trang 3D ---------- */

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

/* Chữ giới thiệu dùng style hero-content gốc, chỉ căn giữa & giới hạn rộng */
.hero-content {
  max-width: 780px;
  text-align: center;
}

/* Khối viewer 3D bên dưới intro */
.viewer-wrapper {
  width: 100%;
}

/* ---------- Card viewer 3D ---------- */

.viewer-card-3d {
  background: var(--bg-card, #ffffff);
  border-radius: 1.25rem;
  border: 1px solid var(--border-color, #e5e7eb);
  box-shadow: var(--shadow-lg, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
  padding: 1.4rem 1.5rem 1rem;
}

/* Header card */

.viewer-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.9rem;
}

.viewer-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.viewer-card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary, #666666);
}

.viewer-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip-small {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: #f3f4ff;
  color: var(--primary-blue, #0066ff);
}

/* ---------- Canvas 3D ---------- */

.viewer-canvas-shell {
  position: relative;
  width: 100%;
  height: 420px;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: radial-gradient(circle at 50% 0%, #111827 0%, #020617 55%, #000 100%);
  margin-bottom: 1rem;
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
}

/* Overlay loading */

.viewer-loading {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.99));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.viewer-spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.3);
  border-top-color: var(--primary-blue, #0066ff);
  animation: spin 0.9s linear infinite;
}

.viewer-loading-text {
  font-size: 0.8rem;
  color: #e5e7eb;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Controls: chọn sản phẩm / góc nhìn / bộ phận ---------- */

.viewer-controls-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.viewer-block {
  background: var(--bg-light, #f9fafb);
  border-radius: 1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-color, #e5e7eb);
}

/* Labels nhỏ trên block */

.viewer-block-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #666666);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.viewer-block-label-inline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 0.55rem;
}

.viewer-block-hint {
  font-size: 0.7rem;
  color: var(--text-light, #999999);
}

/* Select sản phẩm */

.viewer-select-shell {
  margin-top: 0.35rem;
}

.viewer-select-shell select {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border-color, #e5e7eb);
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  color: var(--text-primary, #1a1a1a);
  background: #ffffff;
}

/* Buttons preset camera */

.viewer-view-buttons {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.btn-view {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: #ffffff;
  color: var(--text-secondary, #666666);
  font-size: 0.8rem;
  padding: 0.35rem 0.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-view:hover {
  border-color: var(--primary-blue, #0066ff);
  color: var(--primary-blue-dark, #0052cc);
}

.btn-view.is-active {
  background: linear-gradient(135deg, var(--gradient-start, #0066ff), var(--gradient-end, #00c9ff));
  color: #ffffff;
  border-color: transparent;
}

/* Block BỘ PHẬN */

.viewer-block-parts {
  padding-bottom: 0.5rem;
}

.viewer-parts-toolbar {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.btn-chip {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: #ffffff;
  font-size: 0.75rem;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
  color: var(--text-secondary, #666666);
}

.btn-chip:hover {
  border-color: var(--primary-blue, #0066ff);
  color: var(--primary-blue-dark, #0052cc);
}

.viewer-parts-list {
  margin-top: 0.45rem;
  max-height: 140px;
  overflow: auto;
  padding-right: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.part-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #666666);
}

.part-item input[type="checkbox"] {
  accent-color: var(--primary-blue, #0066ff);
}

/* ---------- Meta: FPS / Polygon / Center ---------- */

.viewer-meta-row {
  display: flex;
  gap: 0.75rem;
}

.viewer-meta-item {
  flex: 0 0 auto;
  min-width: 90px;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-light, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
}

.viewer-meta-label {
  font-size: 0.7rem;
  color: var(--text-light, #999999);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.viewer-meta-value {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary, #1a1a1a);
}

/* ---------- Features section bên dưới viewer ---------- */

.features-section {
  padding: 4rem 0 5rem;
  background: #ffffff;
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  margin-bottom: 0.5rem;
}

.section-description {
  font-size: 0.95rem;
  color: var(--text-secondary, #666666);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: #f9fafb;
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
}

.feature-icon {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.feature-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-secondary, #666666);
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .hero {
    padding: 6rem 2rem 3rem;
  }

  .hero-title {
    font-size: 3rem;
  }

  .viewer-canvas-shell {
    height: 360px;
  }

  .viewer-controls-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 5rem 1.5rem 2.5rem;
  }

  .hero-title {
    font-size: 2.4rem;
  }

  .viewer-card-3d {
    padding: 1.1rem 1.1rem 0.9rem;
  }

  .viewer-canvas-shell {
    height: 260px;
  }
}
/* ---------- Canvas 3D ---------- */
/* ---------- Canvas 3D ---------- */

.viewer-canvas-shell {
  position: relative;
  width: 100%;
  height: 420px;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: radial-gradient(circle at 50% 0%, #111827 0%, #020617 55%, #000 100%);
  margin-bottom: 1rem;
}

/* Fullscreen mode adjustments */
.viewer-canvas-shell:fullscreen {
  border-radius: 0;
  height: 100vh;
  width: 100vw;
  background: #000000;
}

.viewer-canvas-shell:-webkit-full-screen {
  border-radius: 0;
  height: 100vh;
  width: 100vw;
  background: #000000;
}

.viewer-canvas-shell:-moz-full-screen {
  border-radius: 0;
  height: 100vh;
  width: 100vw;
  background: #000000;
}

.viewer-canvas-shell:-ms-fullscreen {
  border-radius: 0;
  height: 100vh;
  width: 100vw;
  background: #000000;
}

/* 🔥 FAKE FULLSCREEN cho iOS Safari */
.viewer-canvas-shell.fake-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 9999 !important;
  background: #000000 !important;
}

.viewer-canvas-shell.fake-fullscreen #viewer {
  width: 100% !important;
  height: 100% !important;
}

/* When in fake fullscreen (iOS), button uses safe-area aware positioning */
.viewer-canvas-shell.fake-fullscreen .btn-fullscreen {
  position: fixed !important;
  bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
  right: calc(0.5rem + env(safe-area-inset-right, 0px)) !important;
  top: auto !important;
  left: auto !important;
  z-index: 10001 !important;
}

/* Fallback for older Safari with constant() */
@supports (bottom: constant(safe-area-inset-bottom)) {
  .viewer-canvas-shell.fake-fullscreen .btn-fullscreen {
    bottom: calc(0.5rem + constant(safe-area-inset-bottom, 0px)) !important;
    right: calc(0.5rem + constant(safe-area-inset-right, 0px)) !important;
  }
}

/* Canvas trong fullscreen */
.viewer-canvas-shell:fullscreen #viewer,
.viewer-canvas-shell:-webkit-full-screen #viewer,
.viewer-canvas-shell:-moz-full-screen #viewer,
.viewer-canvas-shell:-ms-fullscreen #viewer {
  width: 100% !important;
  height: 100% !important;
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
}

/* Fullscreen button */
.btn-fullscreen {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* When in real fullscreen on desktop, button becomes fixed to escape the fullscreened element */
.viewer-canvas-shell:fullscreen .btn-fullscreen,
.viewer-canvas-shell:-webkit-full-screen .btn-fullscreen,
.viewer-canvas-shell:-moz-full-screen .btn-fullscreen,
.viewer-canvas-shell:-ms-fullscreen .btn-fullscreen {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10000;
}

/* When in fake fullscreen (iOS), button uses safe-area aware positioning */
.viewer-canvas-shell.fake-fullscreen .btn-fullscreen {
  position: fixed;
  bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  right: calc(0.5rem + env(safe-area-inset-right, 0px));
  z-index: 10000;
}

/* Fallback for older Safari with constant() */
@supports (bottom: constant(safe-area-inset-bottom)) {
  .viewer-canvas-shell.fake-fullscreen .btn-fullscreen {
    bottom: calc(0.5rem + constant(safe-area-inset-bottom, 0px));
    right: calc(0.5rem + constant(safe-area-inset-right, 0px));
    z-index: 10000;
  }
}

.btn-fullscreen:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.btn-fullscreen:active {
  transform: scale(0.95);
}

.btn-fullscreen .icon-compress {
  display: none;
}

.btn-fullscreen.is-fullscreen .icon-expand {
  display: none;
}

.btn-fullscreen.is-fullscreen .icon-compress {
  display: block;
}

/* Mobile: nút lớn hơn để dễ nhấn */
@media (max-width: 640px) {
  .btn-fullscreen {
    width: 48px;
    height: 48px;
    bottom: 0.75rem;
    right: 0.75rem;
  }
}

/* ========== NEW FEATURES STYLES ========== */

/* Upload zone */
.viewer-upload-zone {
  margin-top: 0.35rem;
  padding: 1rem;
  border: 2px dashed var(--border-color, #e5e7eb);
  border-radius: 0.75rem;
  background: rgba(0, 102, 255, 0.05);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.viewer-upload-zone:hover {
  border-color: var(--primary-blue, #0066ff);
  background: rgba(0, 102, 255, 0.1);
}

.viewer-upload-zone.drag-over {
  border-color: var(--primary-blue, #0066ff);
  background: rgba(0, 102, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.upload-text {
  font-size: 0.8rem;
  color: var(--text-secondary, #666666);
  font-weight: 500;
}

/* Toolbar buttons */
.viewer-toolbar {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.viewer-toolbar .btn-chip {
  flex: 1;
  font-size: 0.75rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10100;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  max-width: 450px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary, #666666);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f3f4f6;
  color: var(--text-primary, #1a1a1a);
}

.modal-body {
  padding: 1.2rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  font-size: 0.9rem;
}

.info-value {
  color: var(--text-secondary, #666666);
  font-size: 0.9rem;
  word-break: break-word;
  text-align: right;
}

/* Responsive adjustments for new sections */
@media (max-width: 1024px) {
  .viewer-controls-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .modal-content {
    max-height: 90vh;
  }
  
  .viewer-toolbar {
    flex-direction: column;
  }
  
  .viewer-toolbar .btn-chip {
    width: 100%;
  }
}
