/* ============================================================
   Booklet Maker Pro — v2.0.0
   ============================================================ */

* { box-sizing: border-box; }

#bmp-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1e293b;
  max-width: 580px;
  margin: 0 auto;
}

/* ── View Tabs ─────────────────────────────────────────────── */
.bmp-tabs { display:flex; gap:6px; margin-bottom:12px; }
.bmp-tab {
  flex:1; padding:9px 4px; border:2px solid #e2e8f0; border-radius:8px;
  background:#fff; font-size:13px; font-weight:600; color:#64748b; cursor:pointer;
  transition:all .14s;
}
.bmp-tab:hover { border-color:#3b82f6; color:#2563eb; }
.bmp-tab.active { border-color:#2563eb; background:#eff6ff; color:#1d4ed8; }

/* ── Canvas ────────────────────────────────────────────────── */
.bmp-canvas-wrap {
  border-radius:12px; overflow:hidden;
  box-shadow:0 4px 24px rgba(0,0,0,.13),0 1px 4px rgba(0,0,0,.08);
  margin-bottom:16px; background:#e8edf2; line-height:0;
}
#bmp-canvas { width:100%; height:auto; display:block; }

/* ── Controls ──────────────────────────────────────────────── */
.bmp-controls {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px;
  padding:16px; margin-bottom:16px; display:flex; flex-direction:column; gap:14px;
}
.bmp-control-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.bmp-control-label {
  font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.07em;
  color:#64748b; width:80px; flex-shrink:0;
}

/* ── CMYK Color Section ────────────────────────────────────── */
.bmp-cmyk-section {
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 2px;
}
.bmp-cmyk-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #64748b; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.bmp-cmyk-only-tag {
  background: #1e293b; color: #fff; font-size: 9px; font-weight: 700;
  letter-spacing: .06em; padding: 2px 6px; border-radius: 3px;
  text-transform: uppercase;
}

/* Palette */
.bmp-cmyk-palette {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px;
}
.bmp-cmyk-swatch {
  width: 24px; height: 24px; border-radius: 4px;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.bmp-cmyk-swatch:hover { transform: scale(1.18); }
.bmp-cmyk-swatch.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb;
  transform: scale(1.1);
}

/* Bottom row */
.bmp-cmyk-bottom {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

/* Selected color preview */
.bmp-selected-color {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.bmp-selected-swatch {
  width: 32px; height: 32px; border-radius: 6px;
  border: 1.5px solid rgba(0,0,0,.12);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  flex-shrink: 0;
}
.bmp-selected-meta { line-height: 1.3; }
.bmp-selected-name {
  font-size: 12px; font-weight: 700; color: #1e293b;
}
.bmp-selected-values {
  font-size: 10px; color: #64748b; font-family: monospace;
}

/* Custom CMYK inputs */
.bmp-cmyk-inputs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.bmp-custom-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.bmp-ci {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bmp-ci span {
  font-size: 9px; font-weight: 800; letter-spacing: .04em;
}
.bmp-ci input {
  width: 38px; padding: 4px 2px; text-align: center;
  border: 1.5px solid #e2e8f0; border-radius: 5px;
  font-size: 12px; font-weight: 600; color: #1e293b;
}
.bmp-ci input:focus { outline: none; border-color: #2563eb; }
.bmp-ci-c span { color: #0099cc; }
.bmp-ci-m span { color: #cc0066; }
.bmp-ci-y span { color: #ccaa00; }
.bmp-ci-k span { color: #333333; }

/* Toggle buttons */
.bmp-toggle { display:flex; gap:6px; }
.bmp-toggle-btn {
  padding:6px 12px; border:2px solid #e2e8f0; border-radius:6px; background:#fff;
  font-size:12px; font-weight:600; color:#64748b; cursor:pointer; transition:all .12s;
}
.bmp-toggle-btn.active { border-color:#2563eb; background:#eff6ff; color:#1d4ed8; }

/* Select */
.bmp-select {
  padding:7px 10px; border:2px solid #e2e8f0; border-radius:6px;
  font-size:13px; color:#1e293b; background:#fff; cursor:pointer;
}
.bmp-select:focus { outline:none; border-color:#2563eb; }

/* Upload area */
.bmp-upload-area {
  display:flex; align-items:center; gap:8px; border:2px dashed #cbd5e1;
  border-radius:8px; padding:8px 12px; cursor:pointer; font-size:12px;
  color:#64748b; background:#fff; flex:1; transition:border-color .13s,background .13s;
}
.bmp-upload-area:hover, .bmp-upload-area.bmp-drag-over {
  border-color:#2563eb; background:#eff6ff; color:#2563eb;
}
#bmp-file-input { display:none; }
.bmp-remove-art {
  background:none; border:none; color:#94a3b8; font-size:11px;
  cursor:pointer; padding:4px 0; white-space:nowrap;
}
.bmp-remove-art:hover { color:#ef4444; }

/* ── Interior Section ──────────────────────────────────────── */
.bmp-interior-section {
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:10px; padding:16px;
}
.bmp-interior-header {
  display:flex; align-items:flex-start; justify-content:space-between;
  margin-bottom:14px; gap:12px;
}
.bmp-interior-title {
  font-size:13px; font-weight:700; color:#1e293b; margin-bottom:2px;
}
.bmp-interior-sub { font-size:11px; color:#64748b; }

.bmp-download-btn {
  display:inline-flex; align-items:center; gap:6px; background:#2563eb; color:#fff;
  border:none; border-radius:8px; padding:9px 14px; font-size:12px; font-weight:700;
  cursor:pointer; white-space:nowrap; transition:opacity .14s;
  flex-shrink:0;
}
.bmp-download-btn:hover:not(:disabled) { opacity:.9; }
.bmp-download-btn:disabled { opacity:.6; cursor:default; }

/* Spreads scrollable strip */
.bmp-spreads {
  display:flex; gap:10px; overflow-x:auto; padding-bottom:8px; scrollbar-width:thin;
}
.bmp-no-spreads { font-size:12px; color:#94a3b8; text-align:center; padding:8px 0; }

/* Spread thumbnail */
.bmp-spread-thumb {
  flex-shrink:0; cursor:pointer; text-align:center;
  transition:transform .12s;
}
.bmp-spread-thumb:hover { transform:translateY(-2px); }
.bmp-thumb-pages {
  display:flex; gap:1px; background:#b0b0b0; border-radius:3px;
  overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,.12);
  border:2px solid transparent; transition:border-color .12s;
}
.bmp-spread-thumb:hover .bmp-thumb-pages { border-color:#2563eb; }
.bmp-spread-thumb.bmp-has-content .bmp-thumb-pages { border-color:#10b981; }

.bmp-page-thumb {
  width:48px; min-height:64px; background:#fff; padding:4px;
  position:relative; overflow:hidden;
}
.bmp-thumb-gutter {
  width:4px;
  background:linear-gradient(to right, #aaa, #ddd, #aaa);
}
.bmp-thumb-label {
  font-size:10px; color:#94a3b8; margin-top:4px; line-height:1;
}
.bmp-edited-dot { color:#10b981; font-size:8px; }

/* Thumbnail regions (absolute within .bmp-page-thumb) */
.bmp-thumb-region { position:absolute; overflow:hidden; }
.bmp-thumb-heading {
  font-size:4px; font-weight:700; color:#1e293b; line-height:1.2;
  background:#f0f0f0; padding:1px 2px; border-radius:1px;
}
.bmp-thumb-text {
  font-size:3px; color:#475569; line-height:1.3; background:#f8f8f8;
  padding:1px 2px;
}
.bmp-thumb-img { background:#dde6f0; }
.bmp-thumb-img-empty {
  background:repeating-linear-gradient(45deg,#e8eef4,#e8eef4 2px,#f0f4f8 2px,#f0f4f8 6px);
}

/* ═══════════════════════════════════════════════════════════════
   EDITOR MODAL
   ═══════════════════════════════════════════════════════════════ */
.bmp-editor-overlay {
  position:fixed; inset:0; background:rgba(15,23,42,.7);
  z-index:99999; overflow-y:auto; padding:16px;
}
.bmp-editor-modal {
  background:#fff; border-radius:12px; max-width:960px; margin:0 auto;
  box-shadow:0 20px 60px rgba(0,0,0,.3); overflow:hidden;
  display:flex; flex-direction:column; max-height:calc(100vh - 32px);
}

/* Header */
.bmp-editor-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 20px; background:#1e293b; flex-shrink:0;
}
.bmp-editor-nav {
  display:flex; align-items:center; gap:12px;
}
.bmp-editor-spread-label { color:#fff; font-weight:700; font-size:15px; }
.bmp-nav-btn {
  background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.2);
  color:#fff; border-radius:6px; padding:5px 10px; font-size:12px;
  font-weight:600; cursor:pointer; transition:background .12s;
}
.bmp-nav-btn:hover:not(:disabled) { background:rgba(255,255,255,.2); }
.bmp-nav-btn:disabled { opacity:.35; cursor:default; }
.bmp-editor-done {
  background:#10b981; border:none; color:#fff; border-radius:8px;
  padding:8px 18px; font-size:13px; font-weight:700; cursor:pointer;
  transition:opacity .12s;
}
.bmp-editor-done:hover { opacity:.9; }

/* Body */
.bmp-editor-body {
  display:flex; gap:0; overflow-y:auto; flex:1; min-height:0;
}
.bmp-editor-col {
  flex:1; padding:16px; min-width:0; overflow-y:auto;
  border-right:1px solid #f0f0f0;
}
.bmp-editor-col:last-child { border-right:none; }
.bmp-editor-gutter {
  width:20px; flex-shrink:0; background:linear-gradient(to right,#e0e0e0,#f5f5f5,#e0e0e0);
  align-self:stretch;
}

/* Layout picker row */
.bmp-layout-row {
  display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px;
}
.bmp-layout-card {
  display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:6px 8px; border:2px solid #e2e8f0; border-radius:6px;
  background:#fff; cursor:pointer; font-size:9px; color:#64748b;
  font-weight:600; transition:all .12s; min-width:44px;
}
.bmp-layout-card:hover { border-color:#3b82f6; color:#2563eb; }
.bmp-layout-card.active { border-color:#2563eb; background:#eff6ff; color:#1d4ed8; }
.bmp-layout-card svg { flex-shrink:0; }

/* Page canvas in editor */
.bmp-editor-page {
  position:relative; width:100%; background:#fff;
  box-shadow:0 2px 12px rgba(0,0,0,.12); border-radius:2px;
  overflow:hidden;
  /* padding-top set via JS to maintain aspect ratio */
}
.bmp-page-regions {
  position:absolute; inset:6%;  /* 6% = margin inside page */
}
.bmp-page-num {
  position:absolute; bottom:6px; left:50%; transform:translateX(-50%);
  font-size:9px; color:#aaa;
}

/* Text region (textarea) */
.bmp-region-text {
  position:absolute; border:1px dashed rgba(37,99,235,.25); border-radius:2px;
  background:rgba(239,246,255,.3); resize:none; outline:none;
  font-family:inherit; color:#1e293b; padding:4px; line-height:1.5;
  width:100%; height:100%; overflow:hidden;
  transition:border-color .12s, background .12s;
}
.bmp-region-text:focus {
  border-color:#2563eb; background:#fff;
  box-shadow:0 0 0 2px rgba(37,99,235,.1);
  z-index:2;
}
.bmp-region-text::placeholder { color:#94a3b8; font-style:italic; }

/* Image region */
.bmp-region-image {
  position:absolute; border:2px dashed #cbd5e1; border-radius:3px;
  background:#f0f4f8; cursor:pointer; overflow:hidden;
  transition:border-color .12s, background .12s;
}
.bmp-region-image:hover { border-color:#2563eb; background:#eff6ff; }
.bmp-img-placeholder {
  position:absolute; inset:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:4px;
  color:#94a3b8; font-size:9px; text-align:center; padding:4px;
}
.bmp-img-placeholder span { font-weight:600; }

/* Blank hint */
.bmp-blank-hint {
  position:absolute; inset:0; display:flex; align-items:center;
  justify-content:center; color:#94a3b8; font-size:11px; text-align:center;
  padding:20px;
}

/* ═══════════════════════════════════════════════════════════════
   LIVE SPREAD PREVIEW
   ═══════════════════════════════════════════════════════════════ */
.bmp-preview-section {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
}
.bmp-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.bmp-preview-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #64748b;
}
.bmp-preview-nav { display: flex; align-items: center; gap: 10px; }
.bmp-flip-btn {
  width: 30px; height: 30px; border: 1.5px solid #cbd5e1; border-radius: 6px;
  background: #fff; font-size: 14px; cursor: pointer; color: #475569;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s; padding: 0;
}
.bmp-flip-btn:hover:not(:disabled) { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.bmp-flip-btn:disabled { opacity: .3; cursor: default; }
.bmp-flip-label { font-size: 12px; color: #64748b; min-width: 130px; text-align: center; }

.bmp-preview-stage { overflow: hidden; }

.bmp-preview-spread {
  display: flex; gap: 0; background: #c8c8c8; border-radius: 3px;
  box-shadow: 0 3px 14px rgba(0,0,0,.13);
  overflow: hidden;
}

.bmp-preview-page {
  flex: 1; background: #fff; position: relative; min-height: 0;
  padding-top: calc(11 / 8.5 * 50%); /* 8.5×11: each page = half spread */
}
.bmp-preview-inner {
  position: absolute; inset: 5%;
}
.bmp-preview-gutter {
  width: 8px; flex-shrink: 0;
  background: linear-gradient(to right, #b0b0b0, #e0e0e0, #b0b0b0);
}
.bmp-preview-pnum {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-size: 9px; color: #aaa;
}
.bmp-preview-region { position: absolute; overflow: hidden; }
.bmp-preview-text-r {
  color: #1e293b; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 20; -webkit-box-orient: vertical;
  white-space: pre-wrap; word-break: break-word;
}
.bmp-preview-img-ph {
  background: repeating-linear-gradient(45deg,#e8eef4,#e8eef4 3px,#f0f4f8 3px,#f0f4f8 9px);
}
.bmp-preview-blank-hint {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; color: #94a3b8; text-align: center; gap: 4px;
}

/* Page flip animations */
@keyframes bmpFlipOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-24px); }
}
@keyframes bmpFlipOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}
@keyframes bmpFlipInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes bmpFlipInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.bmp-flip-out-left  { animation: bmpFlipOutLeft  .22s ease forwards; }
.bmp-flip-out-right { animation: bmpFlipOutRight .22s ease forwards; }
.bmp-flip-in-right  { animation: bmpFlipInRight  .28s ease forwards; }
.bmp-flip-in-left   { animation: bmpFlipInLeft   .28s ease forwards; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .bmp-editor-body { flex-direction:column; }
  .bmp-editor-gutter { width:auto; height:12px; align-self:auto; }
  .bmp-editor-col { border-right:none; border-bottom:1px solid #f0f0f0; }
  .bmp-control-row { flex-wrap:wrap; }
  .bmp-control-label { width:100%; }
}
