/* ═══════════════════════════════════════════════════════════
   WC Door Customizer — Dark Theme v4.9.3
   Theme color: #f1b706 (gold)
   Compact card-based layout, per-pattern independent canvases.
   Category + Product selector, Pattern Library modal.
   Fee model: uploaded images = $80 each, library patterns = free.
   ═══════════════════════════════════════════════════════════ */

/* ── Root container ────────────────────────────────────────── */
#door-app {
  max-width: 820px;
  margin: 36px auto;
  padding: 0 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #e0e0e0;
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────── */
.dc-header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.dc-header-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #f0f0f0;
  letter-spacing: -0.02em;
}

.dc-header-sub {
  font-size: 0.84rem;
  color: #999;
  margin-top: 4px;
}

/* ── Sections ──────────────────────────────────────────────── */
.dc-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.dc-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
  margin-bottom: 10px;
}

/* ── Select ────────────────────────────────────────────────── */
.dc-select {
  width: 100%;
  max-width: 380px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.dc-select:focus {
  border-color: rgba(241,183,6,0.5);
  box-shadow: 0 0 0 3px rgba(241,183,6,0.12);
}

/* ── Category + Product selector row ───────────────────────── */
.dc-select-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.dc-select-group {
  flex: 1;
  min-width: 200px;
}

.dc-select-group .dc-label {
  margin-bottom: 6px;
}

/* ── Warning message (non-customizable product) ────────────── */
.dc-warn-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #f87171;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Lens info banner ──────────────────────────────────────── */
.dc-lens-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: rgba(241, 183, 6, 0.08);
  border: 1px solid rgba(241, 183, 6, 0.25);
  border-radius: 8px;
  color: #f1b706;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
}

/* ── Pattern grid ──────────────────────────────────────────── */
.dc-patterns-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.dc-pattern-card {
  flex: 0 1 260px;
  max-width: 320px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  position: relative;
}

.dc-pattern-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
}

.dc-pattern-card.dc-active {
  border-color: rgba(241,183,6,0.5);
  box-shadow: 0 0 0 1px rgba(241,183,6,0.2), 0 4px 16px rgba(241,183,6,0.06);
  background: rgba(241,183,6,0.05);
}

.dc-pattern-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dc-pattern-card-title {
  font-weight: 600;
  font-size: 0.84rem;
  color: #ccc;
}

.dc-pattern-card-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

.dc-pattern-card-badge.dc-badge-empty {
  background: rgba(255,255,255,0.06);
  color: #777;
}

.dc-pattern-card-badge.dc-badge-filled {
  background: rgba(241,183,6,0.15);
  color: #f1b706;
}

.dc-pattern-card-badge.dc-badge-library {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.dc-pattern-canvas-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Checkerboard pattern — makes transparency visible */
  background-color: #1a1a1a;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dc-pattern-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dc-pattern-card-hint {
  text-align: center;
  font-size: 0.72rem;
  color: #666;
  margin-top: 8px;
}

/* ── Edit area ─────────────────────────────────────────────── */
.dc-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dc-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(241,183,6,0.12);
  color: #f1b706;
}

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

.dc-file-input {
  display: none;
}

.dc-crop-area {
  margin-top: 14px;
  max-width: 420px;
}

.dc-crop-area img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

.dc-edit-hint {
  margin-top: 6px;
  font-size: 0.74rem;
  color: #777;
  font-style: italic;
}

/* ── Buttons ───────────────────────────────────────────────── */
.dc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
  letter-spacing: 0.01em;
}

.dc-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dc-btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #ccc;
}

.dc-btn-outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.3);
}

.dc-btn-primary {
  background: #f1b706;
  color: #1a1a1a;
}

.dc-btn-primary:hover:not(:disabled) {
  background: #f5c524;
  box-shadow: 0 2px 12px rgba(241,183,6,0.3);
  color: #111;
}

.dc-btn-cta {
  background: linear-gradient(135deg, #f1b706, #d4a105);
  color: #1a1a1a;
  padding: 13px 32px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.dc-btn-cta:hover:not(:disabled) {
  background: linear-gradient(135deg, #f5c524, #e0ab10);
  box-shadow: 0 4px 20px rgba(241,183,6,0.3);
  transform: translateY(-1px);
  color: #111;
}

/* ── Button micro-badges ───────────────────────────────────── */
.dc-btn-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.dc-btn-badge-paid {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.dc-btn-badge-free {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

/* ── Summary bar ───────────────────────────────────────────── */
.dc-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 20px;
}

.dc-summary-left {
  flex: 1;
  min-width: 180px;
}

.dc-summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: #aaa;
  padding: 2px 0;
}

.dc-summary-total {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0f0f0;
}

.dc-summary-right {
  flex-shrink: 0;
}

/* ── Cart hint (disabled button explanation) ──────────────── */
.dc-cart-hint {
  font-size: 0.74rem;
  color: #f87171;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 500;
  max-width: 200px;
  line-height: 1.4;
}

/* ── Fee detail text ───────────────────────────────────────── */
.dc-fee-detail {
  font-size: 0.72rem;
  font-weight: 400;
  color: #777;
  font-style: italic;
}

/* ── Pattern Library Modal ─────────────────────────────────── */
.dc-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dc-modal-box {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.dc-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0f0f0;
}

.dc-modal-free-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.03em;
}

.dc-modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.dc-modal-close:hover {
  color: #f1b706;
}

.dc-library-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.dc-library-tab {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: #aaa;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.dc-library-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

.dc-library-tab.dc-active {
  background: rgba(241, 183, 6, 0.15);
  border-color: rgba(241, 183, 6, 0.4);
  color: #f1b706;
}

/* Flexbox wrap — avoids CSS Grid auto-row-height calculation issues entirely.
   Each item has a fixed width; aspect-ratio on the wrapper makes it square. */
.dc-library-grid {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
}

.dc-library-item {
  flex: 1 0 120px;
  max-width: 160px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  background: rgba(255, 255, 255, 0.03);
}

.dc-library-item:hover {
  border-color: rgba(241, 183, 6, 0.5);
  transform: scale(1.03);
}

/* 1:1 square wrapper — aspect-ratio works correctly in flexbox */
.dc-library-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.dc-library-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.dc-library-item-name {
  padding: 6px 8px;
  font-size: 0.72rem;
  color: #999;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Pattern Library search bar ──────────────────────────── */
.dc-library-search {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  position: relative;
}

.dc-search-icon {
  position: absolute;
  left: 32px;
  color: #777;
  pointer-events: none;
}

.dc-search-input {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px 8px 36px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dc-search-input::placeholder {
  color: #666;
}

.dc-search-input:focus {
  border-color: rgba(241, 183, 6, 0.5);
  box-shadow: 0 0 0 3px rgba(241, 183, 6, 0.12);
}

/* ── Pattern Library empty state ─────────────────────────── */
.dc-library-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: #666;
  font-size: 0.9rem;
}

/* ── Pattern Library pagination ──────────────────────────── */
.dc-library-pager {
  flex-shrink: 0;
  padding: 10px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.dc-pager-info {
  font-size: 0.76rem;
  color: #777;
}

.dc-pager-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.dc-pager-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ccc;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dc-pager-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f0f0f0;
}

.dc-pager-btn.dc-pager-active {
  background: rgba(241, 183, 6, 0.15);
  border-color: rgba(241, 183, 6, 0.4);
  color: #f1b706;
  cursor: default;
}

.dc-pager-ellipsis {
  color: #555;
  padding: 0 4px;
  font-size: 0.78rem;
  user-select: none;
}

/* ── Footer info & support link ────────────────────────────── */
.dc-footer-info {
  text-align: center;
  padding: 20px 16px;
  margin-bottom: 16px;
}

.dc-footer-text {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 10px;
}

.dc-footer-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 22px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #f1b706;
  background: rgba(241, 183, 6, 0.08);
  border: 1px solid rgba(241, 183, 6, 0.25);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}

.dc-footer-link:hover {
  background: rgba(241, 183, 6, 0.15);
  border-color: rgba(241, 183, 6, 0.45);
  box-shadow: 0 2px 12px rgba(241, 183, 6, 0.15);
  transform: translateY(-1px);
}

/* ── Cropper overrides (dark) ──────────────────────────────── */
#door-app .cropper-container {
  border-radius: 8px;
  overflow: hidden;
}

#door-app .cropper-modal {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Crop area outline — thick solid gold for high visibility on dark bg */
#door-app .cropper-view-box {
  outline: 2px solid #f1b706;
}

#door-app .cropper-face {
  background-color: transparent;
}

/* Drag handles — gold to match theme */
#door-app .cropper-line,
#door-app .cropper-point {
  background-color: #f1b706;
}

#door-app .cropper-point {
  width: 8px;
  height: 8px;
  opacity: 0.85;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  #door-app {
    margin: 16px auto;
    padding: 0 12px;
  }

  .dc-header-title {
    font-size: 1.25rem;
  }

  .dc-section {
    padding: 14px;
  }

  .dc-pattern-card {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .dc-select-row {
    flex-direction: column;
  }

  .dc-summary-bar {
    flex-direction: column;
    text-align: center;
  }

  .dc-summary-right {
    width: 100%;
  }

  .dc-btn-cta {
    width: 100%;
  }

  .dc-library-item {
    flex: 1 0 90px;
    max-width: 130px;
  }

  .dc-modal-box {
    height: 90vh;
  }

  .dc-library-pager {
    justify-content: center;
  }

  .dc-pager-info {
    width: 100%;
    text-align: center;
  }
}
