/* ================================================================
   FlipIQ — Interactive Demo Modal
   Device frame + simulated app flow matching real scan page UI
   ================================================================ */

/* ========= BACKDROP ========= */
.demo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.demo-backdrop.is-open { opacity: 1; visibility: visible; }

/* ========= MODAL WRAPPER ========= */
.demo-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.demo-modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

/* ========= CLOSE BUTTON ========= */
.demo-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.demo-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ========= DEVICE FRAME — SHARED ========= */
.demo-device {
  position: relative;
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  max-width: 90vw;
  max-height: 90vh;
}
.demo-modal.is-open .demo-device { transform: scale(1); opacity: 1; }

/* ========= PHONE FRAME ========= */
.demo-device--phone { width: 340px; }

.demo-phone-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 19.2;
  background: #0a0a14;
  border-radius: 44px;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.03), 0 40px 80px rgba(0, 0, 0, 0.55), 0 0 80px rgba(168, 85, 247, 0.12);
  overflow: hidden;
}
.demo-phone-shell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: #0a0a14;
  border-radius: 0 0 20px 20px;
  z-index: 5;
}

/* ========= LAPTOP FRAME ========= */
.demo-device--laptop { width: min(820px, 88vw); }

.demo-laptop-shell {
  position: relative;
  width: 100%;
  background: #1a1a2e;
  border-radius: 16px 16px 0 0;
  border: 2.5px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.55), 0 0 80px rgba(168, 85, 247, 0.1);
  overflow: hidden;
}
.demo-laptop-shell::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  z-index: 5;
}
.demo-laptop-screen {
  margin: 24px 12px 12px;
  border-radius: 6px;
  overflow: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: min(50vh, 420px);
  max-height: min(50vh, 420px);
}
.demo-laptop-keyboard {
  width: 106%;
  margin-left: -3%;
  height: 36px;
  background: linear-gradient(180deg, #252540 0%, #1a1a2e 100%);
  border-radius: 0 0 12px 12px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-top: 1.5px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.demo-laptop-trackpad {
  width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
}

/* ========= VIRTUAL SCREEN ========= */
.demo-screen {
  width: 100%;
  height: 100%;
  background: #0f172a;
  color: #f1f5f9;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.demo-device--phone .demo-screen { padding-top: 32px; }

/* ========= APP HEADER (matches real FlipIQ header) ========= */
.demo-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.demo-app-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.demo-app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.demo-app-nav-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}
.demo-app-nav-btn:hover { color: #e2e8f0; background: rgba(255, 255, 255, 0.06); }
.demo-app-new-btn {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.demo-app-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f97316;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

/* ========= SCAN PAGE BODY ========= */
.demo-scan-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.demo-scan-body::-webkit-scrollbar { width: 4px; }
.demo-scan-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }

/* Search bar */
.demo-search-bar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  gap: 8px;
}
.demo-search-input {
  flex: 1;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.demo-search-icon {
  color: #64748b;
  font-size: 16px;
  flex-shrink: 0;
}

/* Upload zone */
.demo-upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  min-height: 180px;
}
.demo-upload-zone:hover {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(255, 255, 255, 0.03);
}
.demo-upload-icon {
  font-size: 36px;
  opacity: 0.3;
}
.demo-upload-text {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}

/* Highlight effect (tutorial-like) */
.demo-highlight {
  border: 2.5px solid #A78BFA !important;
  animation: demo-pulse-glow 2.4s ease-in-out infinite;
}
@keyframes demo-pulse-glow {
  0%, 100% { box-shadow: 0 0 6px #A78BFA; }
  50% { box-shadow: 0 0 18px #A78BFA; }
}

/* FAB button */
.demo-fab {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
  transition: transform 0.15s;
  z-index: 3;
}
.demo-fab:active { transform: scale(0.93); }

/* ========= PHOTO THUMBNAILS ROW ========= */
.demo-thumbs-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.demo-thumb-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}
.demo-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.demo-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: default;
}
.demo-thumb-add {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #64748b;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ========= VIRTUAL GALLERY (file picker) ========= */
.demo-gallery-overlay {
  position: absolute;
  inset: 0;
  background: #0f172a;
  z-index: 6;
  display: flex;
  flex-direction: column;
  animation: demo-slideUp 0.3s ease;
}
@keyframes demo-slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.demo-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.demo-gallery-title {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
}
.demo-gallery-counter {
  font-size: 13px;
  color: #a855f7;
  font-weight: 600;
}
.demo-gallery-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.demo-gallery-grid::-webkit-scrollbar { width: 4px; }
.demo-gallery-grid::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
.demo-gallery-item {
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
  overflow: hidden;
}
.demo-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.15s;
}
.demo-gallery-item.is-placeholder {
  background: linear-gradient(135deg, var(--bg1, #1e293b), var(--bg2, #0f172a));
}
.demo-gallery-item.is-selected::after {
  content: attr(data-num);
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: #a855f7;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.demo-gallery-item.is-selected img { opacity: 0.7; }

/* ========= VIDEO FULLSCREEN ========= */
.demo-video-overlay {
  position: absolute;
  inset: 0;
  background: #2e154d;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
}
.demo-video-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.demo-video-skip {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  z-index: 2;
  transition: background 0.2s;
}
.demo-video-skip:hover { background: rgba(255, 255, 255, 0.2); }

/* ========= CONDITION MODAL (overlay inside device) ========= */
.demo-cond-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: demo-fadeIn 0.25s ease;
}
.demo-cond-card {
  background: #1e293b;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.demo-cond-title {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 16px;
}
.demo-cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.demo-cond-btn {
  padding: 12px 8px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  text-align: center;
}
.demo-cond-btn:hover { border-color: rgba(168, 85, 247, 0.4); color: #e2e8f0; }
.demo-cond-btn.is-active {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.demo-cond-btn.full-width { grid-column: 1 / -1; }
.demo-cond-cancel {
  display: block;
  width: auto;
  margin: 0 auto;
  padding: 8px 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* ========= DETAILS FORM MODAL ========= */
.demo-details-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: demo-fadeIn 0.25s ease;
}
.demo-details-card {
  background: #1e293b;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 80%;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.demo-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.demo-details-title {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
}
.demo-details-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.demo-details-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 16px;
}
.demo-field { margin-bottom: 14px; }
.demo-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.demo-field-badge {
  font-size: 10px;
  font-weight: 600;
  color: #f97316;
  background: rgba(249, 115, 22, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}
.demo-field-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.demo-field-input:focus { border-color: rgba(168, 85, 247, 0.4); }
.demo-details-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.demo-btn-skip {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.demo-btn-validate {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ========= LOADING / PROGRESS ========= */
.demo-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 260px;
  padding: 20px;
}
.demo-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(168, 85, 247, 0.2);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: demo-spin 0.8s linear infinite;
}
@keyframes demo-spin { to { transform: rotate(360deg); } }
.demo-progress-bar {
  width: 80%;
  max-width: 240px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.demo-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.demo-loading-text {
  font-size: 14px;
  color: #94a3b8;
  text-align: center;
}
.demo-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 260px;
}
.demo-skeleton-line {
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  animation: demo-shimmer 1.4s ease-in-out infinite;
}
.demo-skeleton-line:nth-child(1) { width: 90%; }
.demo-skeleton-line:nth-child(2) { width: 70%; animation-delay: 0.1s; }
.demo-skeleton-line:nth-child(3) { width: 80%; animation-delay: 0.2s; }
.demo-skeleton-line:nth-child(4) { width: 55%; animation-delay: 0.3s; }
@keyframes demo-shimmer { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ========= RESULT PAGE ========= */
.demo-result-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #a855f7;
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 10px;
}
.demo-result-photos {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.demo-result-photos img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.demo-result-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.demo-rcard {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
  position: relative;
}
.demo-rcard-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a855f7;
  margin-bottom: 8px;
}
.demo-rcard-copy {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
}
.demo-rcard-title {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
}
.demo-rcard-desc {
  font-size: 12px;
  line-height: 1.7;
  color: #cbd5e1;
  white-space: pre-line;
}
.demo-rcard-price {
  font-size: 22px;
  font-weight: 800;
  color: #f1f5f9;
}
/* 2-col grid on laptop */
.demo-result-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.demo-result-price-row {
  margin-top: 10px;
}
.demo-restart-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 12px;
  transition: transform 0.15s;
}
.demo-restart-btn:active { transform: scale(0.97); }

/* ========= PLACEHOLDER PAGE (nav links) ========= */
.demo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 260px;
  text-align: center;
}
.demo-placeholder-icon { font-size: 40px; opacity: 0.3; }
.demo-placeholder-text { font-size: 14px; color: #94a3b8; max-width: 220px; }
.demo-placeholder-back {
  margin-top: 8px;
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #c084fc;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* ========= TOAST ========= */
.demo-toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 11px;
  color: #e2e8f0;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  text-align: center;
}
.demo-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========= GENERIC ANIMATION ========= */
@keyframes demo-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-step { animation: demo-fadeIn 0.35s ease; }

/* ========= LAPTOP OVERRIDES ========= */
.demo-device--laptop .demo-gallery-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
}
.demo-device--laptop .demo-gallery-item {
  aspect-ratio: 1;
  max-height: 140px;
}
.demo-device--laptop .demo-gallery-header {
  padding: 10px 16px;
}
.demo-device--laptop .demo-scan-body {
  scrollbar-width: none;
}
.demo-device--laptop .demo-scan-body::-webkit-scrollbar {
  display: none;
}

/* ========= RESPONSIVE ========= */
@media (max-width: 1023px) { .demo-device--laptop { display: none; } }
@media (min-width: 1024px) { .demo-device--phone.demo-desktop-hide { display: none; } }
@media (max-height: 700px) { .demo-device--phone { width: 280px; } }
@media (max-height: 580px) { .demo-device--phone { width: 240px; } }
