/* ============================================================================
   AFS BRANDS — INLINE FLOORING PREVIEW & AI ROOM VISUALIZER (OPTION A + B)
   2026-12-01 | 100% Original AFS UI & Canvas Engine | Warm-Stone & Terracotta
   ============================================================================ */

.afs-fv-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  font-family: var(--afs-font-sans, 'DM Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif);
  color: #1C1B19;
  box-sizing: border-box;
}

.afs-fv-root *,
.afs-fv-root *::before,
.afs-fv-root *::after {
  box-sizing: border-box;
}

/* Hide legacy default image & zoom button inside #detail-image when visualizer is active */
#detail-image.afs-fv-active > img,
#detail-image.afs-fv-active > picture,
#detail-image.afs-fv-active > .afs-gallery-stage,
#detail-image.afs-fv-active > .afs-gallery-controls,
#detail-image.afs-fv-active > .afs-gallery-status,
#detail-image.afs-fv-active > .floor-gallery-zoom,
#detail-image.afs-fv-active > .afs-floor-preview-stage {
  display: none !important;
}

#detail-image.afs-fv-active .afs-fv-root button {
  box-shadow: none;
  min-height: 0;
}

#detail-image.afs-fv-active .afs-fv-seg-btn[aria-pressed="true"] {
  background: #1C1B19 !important;
  color: #FFFFFF !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Top bar: View toggle pill + quick actions */
.afs-fv-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
}

.afs-fv-segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid #D8D1C7;
  border-radius: 9px;
  background: #FAF8F5;
}

.afs-fv-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5C564F;
  font: 600 12.5px/1 var(--afs-font-sans, 'DM Sans', system-ui, sans-serif);
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.afs-fv-seg-btn:hover {
  color: #1C1B19;
}

.afs-fv-seg-btn[aria-pressed="true"] {
  background: #1C1B19;
  color: #FFFFFF;
}

.afs-fv-seg-btn:focus-visible,
.afs-fv-action-btn:focus-visible,
.afs-fv-scene-btn:focus-visible,
.afs-fv-pattern-btn:focus-visible {
  outline: 2px solid #A45136;
  outline-offset: 2px;
}

.afs-fv-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.afs-fv-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #D8D1C7;
  border-radius: 8px;
  background: #FFFFFF;
  color: #1C1B19;
  font: 600 12px/1 var(--afs-font-sans, 'DM Sans', system-ui, sans-serif);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.afs-fv-action-btn:hover {
  border-color: #A45136;
  color: #8F4B35;
  background: #FAF6F2;
}

.afs-fv-action-btn--accent {
  border-color: #A45136;
  background: #A45136;
  color: #FFFFFF;
}

.afs-fv-action-btn--accent:hover {
  border-color: #8C422B;
  background: #8C422B;
  color: #FFFFFF;
}

.afs-fv-action-btn[aria-expanded="true"] {
  background: #1C1B19;
  border-color: #1C1B19;
  color: #FFFFFF;
}

.afs-fv-action-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Main 16:9 Stage */
.afs-fv-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #E5E0D8;
  border-radius: 12px;
  background: #F4F1EB;
  overflow: hidden;
}

.afs-fv-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.afs-fv-ai-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #F4F1EB;
}

.afs-fv-ai-img[hidden] {
  display: none !important;
}

.afs-fv-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(24, 25, 23, 0.80);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.afs-fv-ai-switch {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(28, 27, 25, 0.16);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.afs-fv-ai-switch[hidden] {
  display: none !important;
}

.afs-fv-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(250, 248, 245, 0.88);
  backdrop-filter: blur(3px);
  color: #1C1B19;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  padding: 20px;
}

.afs-fv-loading[hidden] {
  display: none !important;
}

.afs-fv-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #E5E0D8;
  border-top-color: #A45136;
  border-radius: 50%;
  animation: afs-fv-spin 0.8s linear infinite;
}

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

/* Controls strip below stage: Room Scenes + Installation Pattern */
.afs-fv-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #E5E0D8;
  border-radius: 10px;
  background: #FAF8F5;
}

.afs-fv-control-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.afs-fv-control-row[hidden] {
  display: none !important;
}

.afs-fv-control-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8F4B35;
}

.afs-fv-scenes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

#detail-image .afs-fv-scene-btn,
.afs-fv-scene-btn {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 4px !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 4px !important;
  border: 1.5px solid #E5E0D8 !important;
  border-radius: 8px !important;
  background: #FFFFFF !important;
  color: #4F4A44 !important;
  font: 600 11px/1.2 var(--afs-font-sans, 'DM Sans', system-ui, sans-serif) !important;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

#detail-image .afs-fv-scene-btn img,
.afs-fv-scene-btn img {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 66px !important;
  aspect-ratio: 16 / 9 !important;
  object-fit: cover !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 5px !important;
}

#detail-image .afs-fv-scene-btn[aria-pressed="true"],
.afs-fv-scene-btn[aria-pressed="true"] {
  border-color: #A45136 !important;
  background: #FAF6F2 !important;
  color: #8F4B35 !important;
  box-shadow: 0 0 0 1px #A45136 !important;
}

.afs-fv-scene-btn span {
  padding-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.afs-fv-scene-btn:hover {
  border-color: #A45136;
  color: #1C1B19;
}

.afs-fv-scene-btn[aria-pressed="true"] {
  border-color: #A45136;
  color: #8F4B35;
  box-shadow: 0 0 0 1px #A45136;
}

.afs-fv-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.afs-fv-pattern-btn {
  height: 30px;
  padding: 0 11px;
  border: 1px solid #D8D1C7;
  border-radius: 999px;
  background: #FFFFFF;
  color: #4F4A44;
  font: 500 12px/1 var(--afs-font-sans, 'DM Sans', system-ui, sans-serif);
  cursor: pointer;
  transition: all 0.14s ease;
}

.afs-fv-pattern-btn:hover {
  border-color: #A45136;
  color: #8F4B35;
}

.afs-fv-pattern-btn[aria-pressed="true"] {
  background: #1C1B19;
  border-color: #1C1B19;
  color: #FFFFFF;
  font-weight: 600;
}

/* Option B: View in Your Room (AI 2K Panel) */
.afs-fv-ai-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #E2D9CC;
  border-radius: 10px;
  background: #FFFFFF;
}

.afs-fv-ai-panel[hidden] {
  display: none !important;
}

.afs-fv-ai-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.afs-fv-ai-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1C1B19;
}

.afs-fv-ai-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: #5C564F;
}

.afs-fv-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.afs-fv-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px dashed #B9AFA2;
  border-radius: 8px;
  background: #FAF8F5;
  color: #1C1B19;
  font: 600 12.5px/1 var(--afs-font-sans, 'DM Sans', system-ui, sans-serif);
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.afs-fv-upload-label:hover {
  border-color: #A45136;
  background: #FAF3EE;
}

.afs-fv-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.afs-fv-upload-status {
  font-size: 12px;
  color: #5C564F;
}

.afs-fv-ai-error {
  margin: 0;
  font-size: 12.5px;
  color: #9B2C1F;
}

.afs-fv-ai-error:empty {
  display: none;
}

/* Concept Visualization Disclosure */
.afs-fv-render-note {
  margin: -4px 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: #6B655D;
}

.afs-fv-disclosure {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #EAE5DD;
  border-radius: 8px;
  background: #FAF8F5;
  font-size: 11.5px;
  line-height: 1.45;
  color: #5C564F;
}

.afs-fv-disclosure strong {
  color: #1C1B19;
  font-weight: 600;
}

@media (max-width: 680px) {
  .afs-fv-scenes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .afs-fv-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .afs-fv-segmented {
    justify-content: space-between;
  }

  .afs-fv-seg-btn {
    flex: 1 1 0;
    padding: 0 8px;
  }

  .afs-fv-actions {
    justify-content: space-between;
  }

  .afs-fv-action-btn {
    flex: 1 1 0;
  }
}
