/* =========================
   MODAL BASE
========================= */
.af-editor-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 999999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* =========================
   MODAL CONTENT
========================= */
.af-editor-content {
  background: #ffffff;
  width: 96vw;
  max-width: 1280px;
  min-height: 92vh;
  padding: 32px 36px;
  padding-top: 64px;
  border-radius: 16px;
  position: relative;
  text-align: left;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
}

.af-editor-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  padding-top: 6px; /* 👈 small downward shift */
  font-size: 20px;
  line-height: 1.3;
}

/* =========================
   SLIDER LAYERING
========================= */
.af-frame-thumb {
  position: relative;
  height: 240px;
  background: #f6f6f6;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner frame area (matches 95%) */
.af-frame-inner {
  position: relative;
  width: 95%;
  height: 95%;
  overflow: hidden;          /* this is key */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Slideshow fills only inner area */
.af-slide-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.6s ease-in-out;
  z-index: 1;
}

@media(max-width: 786px){.af-slide-image {z-index: 2 !important;}}
@media(max-width: 786px){.af-frame-overlay {z-index: -1 !important;}}
@media(max-width: 786px){.af-frame-inner {height: 100% !important;}}

/* Frame overlay */
.af-frame-overlay {
  position: absolute;
  width: 95% !important;
  height: 95% !important;
  object-fit: contain;
  z-index: 2;
  pointer-events: none;
}

/* =========================
   CLOSE BUTTON
========================= */
.af-close {
  position: absolute;
  top: 18px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f1f1f1;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  pointer-events: all;
}

.af-close:hover {
  background: #e5e5e5;
}

/* Enable scrolling in Size & Thickness modal */
#af-sizeModal .af-editor-content {
  max-height: 90vh;          /* 👈 fit within screen */
  overflow-y: auto;          /* 👈 vertical scroll */
  -webkit-overflow-scrolling: touch; /* smooth mobile scroll */
}
body.af-modal-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  #af-sizeModal .af-editor-content {
    max-height: 100vh;
    padding-bottom: 90px; /* 👈 space for Buy button */
  }
}

/* MOBILE: Move thickness preview to top-center */
@media (max-width: 600px) {

  .af-dimension-thickness {
    top: 10px !important;                 /* move to top */
    left: 50%;                 /* center horizontally */
    right: auto;               /* reset desktop rule */
    transform: translateX(-50%);
    font-size: 13px;
    white-space: nowrap;
  }

}

/* =========================
   CANVAS WRAPPER
========================= */
.af-canvas-wrap {
  margin: 20px auto;
  padding: 10px;
  background: #fafafa;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  position: relative;
  cursor: pointer;
}

#af-canvas {
  border: 2px dashed #d1d5db;
  background: #f2f2f2;
  display: block;
}

/* =========================
   CLICK TO UPLOAD OVERLAY
========================= */
.af-canvas-wrap::after {
  content: "Double Click to upload photo";
  position: absolute;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.af-canvas-wrap:not(.af-has-image):hover::after {
  opacity: 1;
}

.af-canvas-wrap.af-has-image::after {
  display: none;
}

/* =========================
   EDITOR TOOLS
========================= */
.af-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

.af-tools button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.af-tools button:hover {
  background: #f3f4f6;
}

.af-tools button:active,
.af-primary:active {
  transform: scale(0.97);
}

/* =========================
   PRIMARY BUTTON
========================= */
.af-primary {
  margin-top: 20px;
  padding: 12px 26px;
  background: #d60000;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.af-primary:hover {
  background: #b50000;
}

/* =========================
   EDITOR ERROR
========================= */
.af-error {
  margin-top: 10px;
  color: #d60000;
  font-size: 14px;
  font-weight: 500;
  display: none;
}

/* =========================
   SIZE & THICKNESS BUTTONS
========================= */
.af-sizes,
.af-thickness {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
}

.af-sizes button,
.af-thickness button {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.af-sizes button:hover,
.af-thickness button:hover {
  border-color: #d60000;
  color: #d60000;
}

.af-sizes button.af-active,
.af-thickness button.af-active {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* =========================
   WALL PREVIEW MOCKUP
========================= */
.af-wall-preview {
  display: flex;
  justify-content: center;
  align-items: center;
}

.af-wall-mockup {
  position: relative;
  width: 520px;
  height: 360px;
  margin: 0 auto;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.af-wall-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  max-height: 70%;
}

.af-wall-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
}

@media(max-width: 786px){.af-wall-frame img {margin-bottom: 95px;}}

/* =========================
   DIMENSIONS
========================= */
.af-dimension {
  position: absolute;
  font-size: 13px;
  color: #000;
  font-weight: 500;
  background: rgba(255,255,255,0.8);
  padding: 4px 8px;
  border-radius: 6px;
}

.af-dimension-width {
  left: 10px;
  top: 50%;
  transform: rotate(-90deg) translateX(-50%);
  transform-origin: left;
}

.af-dimension-height {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.af-dimension-thickness {
  top: 35%;
  right: 10px;
}

/* =========================
   FRAME GRID
========================= */
.af-frame-grid {
  display: grid;
  grid-template-columns: repeat(3, 260px);
  justify-content: center;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
}

@media(max-width: 1024px){.af-frame-grid {
  grid-template-columns: repeat(2, 1fr);
}}

@media(max-width: 600px){.af-frame-grid {
  grid-template-columns: 1fr;
}}

.af-frame-card {
  background: #ffffff;
  padding: 20px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.af-frame-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.12);
}

.af-frame-card h4 {
  font-size: 18px;
  margin: 15px 0 10px;
  min-height: 48px; /* ensures equal title space */
  display: flex;
  align-items: center;
  justify-content: center;
}

.af-customise-btn {
  margin-top: auto;  /* pushes button to bottom */
  background: #d60000;
  color: #ffffff;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}

.af-customise-btn:hover {
  background: #b50000;
}

/* =========================
   SIZE MODAL LAYOUT
========================= */
.af-editor-size-layout {
  max-width: 1380px;
}

.af-size-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  margin-top: 20px;
}

.af-size-preview {
  display: flex;
  justify-content: center;
}

.af-wall-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.af-size-options {
  text-align: left;
}

.af-price-wrap {
  margin-bottom: 24px;
}

.af-price-current {
  font-size: 34px;
  font-weight: 800;
  color: #111;
  letter-spacing: -0.5px;
}

.af-price-old {
  font-size: 16px;
  color: #9b9b9b;
  margin-top: 6px;
  text-decoration: line-through;
}

.af-buy-btn {
  width: 100%;
  margin-top: 30px;
}

#af-editorModal .af-primary {
  width: auto;              /* remove full width */
  min-width: 220px;         /* optional fixed width */
  padding: 10px 22px;       /* reduce height */
  font-size: 14px;          /* smaller text */
  border-radius: 8px;
  align-self: center;       /* center horizontally */
}

#af-sizeModal .af-buy-btn {
  width: 240px;            /* remove full width */
  padding: 10px 22px;
  font-size: 14px;
  border-radius: 8px;
  margin: 25px auto 0;
  display: block;          /* center it */
}

/* =========================
   MOBILE
========================= */
@media (max-width: 600px) {
  .af-editor-content {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    padding: 20px;
    padding-top: 72px;
  }
  
  .af-close {
    top: 16px;
    right: 12px;
  }
  
  .af-editor-content h2 {
    font-size: 18px;
  }

  .af-tools button {
    font-size: 13px;
    padding: 6px 10px;
  }

  .af-wall-mockup {
    width: 100%;
    height: 300px;
  }
  
  .af-wall-frame {
    max-width: 80%;
    max-height: 80%;
  }

  .af-size-layout {
    grid-template-columns: 1fr;
  }
}