/* ═══════════════════════════════════════════════
   Custonder — Theme Extension Styles
   Button + Drawer Overlay + Drawer Panel + Iframe + Skeleton
   ═══════════════════════════════════════════════ */

/* ── Root (theme color tokens inherit into sticky CTA) ── */
.custonder-root {
  --border-width: 1px;
  --font-size: 16px;
  --text-transform: none;
}

/* ── Custom component host ── */
.custonder-block {
  display: block;
  margin-block: 12px;
}

/* ── Button (matches giftmile Create Free Preview CTA) ── */
.custonder-block-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border-radius: var(--border-radius, 12px);
  border: none;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  padding: 10px 16px;
  text-transform: var(--text-transform, none);
  /* giftmile theme: orange-600=#f97316, hover orange-700=#ea580c */
  background-color: var(--background, #f97316);
  color: var(--color, #fff);
  font-size: var(--font-size, 16px);
  box-shadow: 0 4px 6px -1px rgba(67, 20, 7, 0.1), 0 2px 4px -2px rgba(67, 20, 7, 0.1);
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.custonder-block-btn:hover:not(:disabled):not(.loading) {
  background-color: var(--background-hover, #ea580c);
}

.custonder-block-btn:active:not(:disabled):not(.loading) {
  transform: scale(0.98);
}

.custonder-block-btn-icon {
  display: block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.custonder-block-btn-arrow {
  transition: transform 0.2s ease;
}

.custonder-block-btn:hover:not(:disabled):not(.loading) .custonder-block-btn-arrow {
  transform: translateX(2px);
}

.custonder-block-btn-label {
  line-height: 1;
}

/* Loading state — shown before JS initializes */
.custonder-block-btn.loading {
  pointer-events: none;
  opacity: 0.7;
  cursor: wait;
}

.custonder-block-btn.loading .custonder-block-btn-icon {
  display: none;
}

.custonder-block-btn.loading .custonder-block-btn-label {
  font-size: 0;
}

.custonder-block-btn.loading .custonder-block-btn-label::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: custonder-btn-spin 0.6s linear infinite;
}

@keyframes custonder-btn-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Mobile sticky bar (viewport-fixed; .visible when inline CTA is off-screen) ── */
.custonder-sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100vw;
  z-index: 999;
  box-sizing: border-box;
  transform: translateY(100%);
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s ease;
}

.custonder-sticky-bar.is-visible {
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.custonder-sticky-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.custonder-sticky-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.custonder-sticky-thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 2px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #fed7aa;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.custonder-sticky-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  object-fit: cover;
}

.custonder-sticky-meta {
  min-width: 0;
}

.custonder-sticky-prices {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.custonder-sticky-price {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #020617;
}

.custonder-sticky-compare {
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  color: #94a3b8;
  text-decoration: line-through;
}

.custonder-sticky-guarantee {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: #047857;
}

.custonder-sticky-guarantee svg {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
}

.custonder-sticky-cta {
  width: auto;
  flex-shrink: 0;
  min-height: 44px;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 6px -1px rgba(67, 20, 7, 0.1), 0 2px 4px -2px rgba(67, 20, 7, 0.1);
}

.custonder-sticky-cta .custonder-block-btn-icon {
  width: 14px;
  height: 14px;
}

@media (min-width: 769px) {
  .custonder-sticky-bar {
    display: none !important;
  }
}

/* ── Drawer Overlay ── */
/* Always in DOM (for iframe preloading), invisible + non-interactive when closed */
.custonder-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999999999;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.3s ease;
  /* block scroll pass-through */
  overscroll-behavior: none;
}

.custonder-drawer-overlay.open {
  background: rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

/* ── Drawer Panel ── */
/* Always in DOM, slides in/out via transform */
.custonder-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 99999;
  width: 1320px;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  /* prevent scroll chaining to parent page */
  overscroll-behavior: contain;
}

.custonder-drawer.open {
  transform: translateX(0);
}

/* ── Drawer body (wraps skeleton + iframe) ── */
.custonder-drawer-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* ── Drawer Iframe ── */
.custonder-drawer-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Drawer close button (parent-level, always clickable) ── */
.custonder-drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: #374151;
  cursor: pointer;
  transition: background 0.2s ease;
}

.custonder-drawer-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.custonder-drawer-close.is-hidden {
  display: none;
}

/* ── Mobile: bottom sheet ── */
@media (max-width: 768px) {
  .custonder-drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
  }

  .custonder-drawer.open {
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════
   Skeleton placeholder — shown while iframe loads
   ═══════════════════════════════════════════════ */

.custonder-skeleton-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: #f9fafb;
  overflow: hidden;
}

/* ── Shimmer animation ── */
@keyframes custonder-shimmer {
  0% {
    background-position: -600px 0;
  }
  100% {
    background-position: 600px 0;
  }
}

.custonder-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
  background-size: 600px 100%;
  animation: custonder-shimmer 1.6s infinite ease-in-out;
  border-radius: 8px;
}

/* ── Skeleton body: canvas + panel layout (full height, no header) ── */
.custonder-skeleton-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Left: canvas area */
.custonder-skeleton-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.custonder-skeleton-canvas-block {
  width: 60%;
  max-width: 320px;
  height: 60%;
  max-height: 360px;
  border-radius: 12px;
}

/* Right: settings panel */
.custonder-skeleton-panel {
  width: 520px;
  min-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 24px 20px;
  border-left: 1px solid #e5e7eb;
  background: #ffffff;
  overflow-y: hidden;
}

.custonder-skeleton-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.custonder-skeleton-section-title {
  width: 90px;
  height: 13px;
}

/* Drop zone skeleton */
.custonder-skeleton-dropzone {
  width: 100%;
  height: 110px;
  border-radius: 12px;
  border: 2px dashed #e5e7eb;
  background: transparent;
}

/* Text input skeleton */
.custonder-skeleton-input {
  width: 100%;
  height: 40px;
  border-radius: 8px;
}

/* Divider */
.custonder-skeleton-divider {
  width: 100%;
  height: 1px;
  background: #e5e7eb;
  margin: 8px 0;
}

/* Save button skeleton */
.custonder-skeleton-save-btn {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  margin-top: auto;
}

/* ── Skeleton hidden state ── */
.custonder-drawer-body.iframe-ready .custonder-skeleton-placeholder {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* ── Mobile skeleton adjustments ── */
@media (max-width: 768px) {
  .custonder-skeleton-panel {
    width: 320px;
    min-width: 320px;
  }
}

@media (max-width: 480px) {
  .custonder-skeleton-body {
    flex-direction: column;
  }

  .custonder-skeleton-canvas {
    height: 40%;
    flex: none;
  }

  .custonder-skeleton-canvas-block {
    width: 80%;
    height: 70%;
    max-height: 200px;
  }

  .custonder-skeleton-panel {
    width: 100%;
    min-width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }
}
