/* ═══════════════════════════════════════════════
   Custonder — Theme Extension Styles
   Button + Drawer Overlay + Drawer Panel + Iframe + Skeleton
   ═══════════════════════════════════════════════ */

/* ── Custom component host ── */
.custonder-block {
  --border-width: 1px;
  --font-size: 16px;
  --text-transform: capitalize;
  display: block;
  margin-block: 12px;
}

/* ── Button ── */
.custonder-block-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: var(--border-radius, 8px);
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding-block: 12px;
  padding-inline: calc(var(--border-width, 1px) + 12px);
  text-transform: var(--text-transform, capitalize);
  background-color: var(--background, #f97316);
  color: var(--color, #fff);
  font-size: var(--font-size, 16px);
  transition: filter 0.2s ease;
}

.custonder-block-btn:hover {
  filter: brightness(1.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-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 ── */
@media (max-width: 768px) {
  .custonder-sticky-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    padding: 20px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }

  .custonder-sticky-bar.visible {
    transform: translateY(0);
  }
}

/* ── 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;
  }
}
