/* ============================================================
   Livro Publicador — Frontend CSS
   ============================================================ */

:root {
  --lp-primary:    #2196F3;
  --lp-primary-dk: #1565C0;
  --lp-success:    #43A047;
  --lp-warning:    #F9A825;
  --lp-danger:     #E53935;
  --lp-bg:         #F4F5F7;
  --lp-card:       #FFFFFF;
  --lp-border:     #E0E0E0;
  --lp-text:       #212121;
  --lp-muted:      #757575;
  --lp-toolbar-bg: #F57C00;
  --lp-radius:     10px;
  --lp-shadow:     0 2px 12px rgba(0,0,0,.10);
  --lp-shadow-lg:  0 6px 28px rgba(0,0,0,.15);
}

/* ── Reset ──────────────────────────────────────────────── */
.lp-app *, .lp-app *::before, .lp-app *::after { box-sizing: border-box; margin: 0; padding: 0; }
.lp-app { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--lp-text); background: var(--lp-bg); border-radius: var(--lp-radius); overflow: hidden; position: relative; min-height: 420px; }

/* ── Progress ───────────────────────────────────────────── */
.lp-progress { display: flex; align-items: center; background: var(--lp-card); padding: 20px 40px; border-bottom: 1px solid var(--lp-border); }
.lp-progress__step { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lp-progress__num { width: 34px; height: 34px; border-radius: 50%; background: var(--lp-border); color: var(--lp-muted); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; transition: background .3s, color .3s; }
.lp-progress__step span { font-size: 12px; color: var(--lp-muted); white-space: nowrap; }
.lp-progress__step.active .lp-progress__num { background: var(--lp-primary); color: #fff; }
.lp-progress__step.done .lp-progress__num { background: var(--lp-success); color: #fff; }
.lp-progress__step.active span, .lp-progress__step.done span { color: var(--lp-text); font-weight: 600; }
.lp-progress__line { flex: 1; height: 3px; background: var(--lp-border); margin: 0 12px; border-radius: 2px; }

/* ── Step container ─────────────────────────────────────── */
.lp-step { padding: 36px 40px; }
.lp-step--full { padding: 0; }
.lp-step__header { margin-bottom: 28px; }
.lp-step__header h2 { font-size: 22px; font-weight: 700; color: var(--lp-text); }
.lp-step__header p  { color: var(--lp-muted); margin-top: 6px; }

/* ── Buttons ────────────────────────────────────────────── */
.lp-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 50px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .18s; }
.lp-btn:disabled { opacity: .4; cursor: not-allowed; }
.lp-btn--primary  { background: var(--lp-primary);  color: #fff; }
.lp-btn--primary:hover:not(:disabled) { background: var(--lp-primary-dk); }
.lp-btn--success  { background: var(--lp-success);  color: #fff; }
.lp-btn--success:hover:not(:disabled) { filter: brightness(1.08); }
.lp-btn--ghost    { background: transparent; color: var(--lp-muted); border: 2px solid var(--lp-border); }
.lp-btn--ghost:hover { border-color: var(--lp-primary); color: var(--lp-primary); }
.lp-btn--outline  { background: transparent; color: var(--lp-primary); border: 2px solid var(--lp-primary); }
.lp-btn--outline:hover { background: var(--lp-primary); color: #fff; }
.lp-btn--dark     { background: #37474F; color: #fff; }
.lp-btn--dark:hover { background: #263238; }
.lp-btn--lg { padding: 14px 32px; font-size: 16px; }
.lp-btn--sm { padding: 6px 14px; font-size: 13px; }
.lp-icon-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--lp-border); background: var(--lp-card); cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.lp-icon-btn:hover { background: var(--lp-primary); color: #fff; border-color: var(--lp-primary); }
.lp-icon-btn--reset { border-radius: 20px; width: auto; padding: 0 10px; font-size: 12px; }

/* ── Upload zone ────────────────────────────────────────── */
.lp-upload-zone { border: 2.5px dashed var(--lp-primary); border-radius: var(--lp-radius); padding: 56px 24px; text-align: center; background: #E3F2FD; cursor: pointer; transition: background .2s, border-color .2s; }
.lp-upload-zone.drag-over { background: #BBDEFB; border-color: var(--lp-primary-dk); }
.lp-upload-zone__icon { font-size: 52px; line-height: 1; margin-bottom: 14px; }
.lp-upload-zone__title { font-size: 16px; font-weight: 600; color: var(--lp-text); margin-bottom: 6px; }
.lp-upload-zone__sub   { color: var(--lp-muted); font-size: 13px; margin-bottom: 18px; }

/* ── Info cards ─────────────────────────────────────────── */
.lp-miolo-info { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.lp-info-card { display: flex; align-items: flex-start; gap: 14px; background: var(--lp-card); border: 1px solid var(--lp-border); border-radius: var(--lp-radius); padding: 16px 20px; box-shadow: var(--lp-shadow); }
.lp-info-card--blue { background: #E3F2FD; border-color: #90CAF9; }
.lp-info-card__icon { font-size: 22px; flex-shrink: 0; }
.lp-info-card__body strong { display: block; font-size: 14px; margin-bottom: 4px; color: var(--lp-primary); }
.lp-info-card__body p { font-size: 13px; color: var(--lp-muted); margin: 2px 0; }

/* ── Checklist box ──────────────────────────────────────── */
.lp-checklist-box { background: var(--lp-card); border: 1px solid var(--lp-border); border-radius: var(--lp-radius); padding: 16px 20px; box-shadow: var(--lp-shadow); }
.lp-checklist-box__title { font-size: 14px; font-weight: 600; color: var(--lp-text); margin-bottom: 10px; }
.lp-checklist-box ul { padding-left: 20px; }
.lp-checklist-box li { font-size: 13px; color: var(--lp-muted); margin-bottom: 4px; }

/* ── PDF preview ────────────────────────────────────────── */
.lp-miolo-preview-wrap { background: #888; border-radius: var(--lp-radius); overflow: hidden; margin-top: 20px; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.lp-miolo-preview-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; background: rgba(255,255,255,.12); padding: 8px 16px; border-radius: 8px; }
.lp-miolo-preview-toolbar span { color: #fff; font-size: 13px; }
#lp-pdf-canvas { max-width: 100%; box-shadow: 0 4px 24px rgba(0,0,0,.4); border-radius: 3px; }

/* ── Toggle switches ────────────────────────────────────── */
.lp-switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.lp-switch input { opacity: 0; width: 0; height: 0; }
.lp-switch__track { position: absolute; inset: 0; background: #ccc; border-radius: 11px; cursor: pointer; transition: background .2s; }
.lp-switch__track::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: left .2s; }
.lp-switch input:checked + .lp-switch__track { background: var(--lp-primary); }
.lp-switch input:checked + .lp-switch__track::after { left: 22px; }
.lp-switch--inline { margin: 0 4px; }
.lp-toggle-wrap { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.lp-switch-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #fff; }

/* ── Checkbox ───────────────────────────────────────────── */
.lp-checkbox-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.lp-checkbox-label input[type=checkbox] { display: none; }
.lp-checkbox-box { width: 20px; height: 20px; min-width: 20px; border: 2px solid var(--lp-primary); border-radius: 4px; background: #fff; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.lp-checkbox-label input:checked ~ .lp-checkbox-box,
.lp-checkbox-label:has(input:checked) .lp-checkbox-box { background: var(--lp-primary); }
.lp-checkbox-label:has(input:checked) .lp-checkbox-box::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; }

/* ── Range input ────────────────────────────────────────── */
.lp-range { -webkit-appearance: none; appearance: none; height: 6px; background: #ddd; border-radius: 3px; outline: none; cursor: pointer; }
.lp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--lp-primary); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.lp-range--sm  { width: 100px; }
.lp-range--full { width: 100%; max-width: 600px; }

/* ── Step 2 layout ──────────────────────────────────────── */
.lp-step2-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.lp-step2-left { display: flex; flex-direction: column; gap: 18px; }
.lp-check-item { background: var(--lp-card); border: 1px solid var(--lp-border); border-radius: var(--lp-radius); padding: 18px 20px; box-shadow: var(--lp-shadow); }
.lp-orelha-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--lp-border); }
.lp-orelha-slider-wrap { margin-top: 14px; background: var(--lp-bg); border-radius: 8px; padding: 14px; border: 1px solid var(--lp-border); }
.lp-field-label { font-size: 13px; font-weight: 600; color: var(--lp-text); display: block; margin-bottom: 8px; }
.lp-field-label small { font-weight: 400; color: var(--lp-muted); }
.lp-range-row { display: flex; align-items: center; gap: 12px; }
.lp-range-min, .lp-range-max { font-size: 11px; color: var(--lp-muted); text-align: center; line-height: 1.3; }
.lp-range-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lp-range-value { background: var(--lp-bg); border: 1px solid var(--lp-border); border-radius: 6px; padding: 6px 16px; font-size: 15px; font-weight: 700; color: var(--lp-text); min-width: 60px; text-align: center; }
.lp-dimensions-summary { margin-top: 14px; background: var(--lp-bg); border-radius: 8px; padding: 12px 16px; font-size: 13px; color: var(--lp-muted); }
.lp-dimensions-summary p { margin-bottom: 4px; }
.lp-dimensions-summary b { color: var(--lp-text); }
.lp-step2-actions { display: flex; justify-content: flex-end; }
.lp-step2-right { display: flex; align-items: flex-start; justify-content: center; }
.lp-diagram-wrap svg { max-width: 100%; border-radius: var(--lp-radius); background: var(--lp-card); box-shadow: var(--lp-shadow); }

/* ── Visualizer toolbar ─────────────────────────────────── */
.lp-visualizer-toolbar { background: var(--lp-toolbar-bg); display: flex; align-items: center; gap: 20px; padding: 10px 18px; flex-wrap: wrap; }
.lp-toolbar-group { display: flex; align-items: center; gap: 8px; }
.lp-toolbar-num { color: rgba(255,255,255,.9); font-size: 12px; font-weight: 700; white-space: nowrap; }
.lp-close-btn { margin-left: auto; background: #E53935; border: none; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; }

/* ── Visualizer canvas ──────────────────────────────────── */
.lp-visualizer-canvas-wrap { position: relative; background: #E0E0E0; min-height: 460px; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lp-vis-book { position: relative; display: inline-block; line-height: 0; border: 2px solid #bbb; }
.lp-vis-book img { display: block; max-height: 440px; max-width: 900px; width: auto; }
.lp-vis-overlay { position: absolute; inset: 0; pointer-events: none; display: flex; }
/* Zones */
.lp-vis-zone { display: flex; align-items: center; justify-content: center; opacity: .55; }
.lp-vis-zone span { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.4); letter-spacing: 1px; }
.lp-zone--vert { writing-mode: vertical-rl; transform: rotate(180deg); }
.lp-zone--orelha     { background: rgba(255,230,80,.6); flex: 0 0 12%; }
.lp-zone--contracapa { background: rgba(100,140,255,.5); flex: 1; }
.lp-zone--lombada    { background: rgba(60,200,100,.7);  flex: 0 0 5%; }
.lp-zone--capa       { background: rgba(100,140,255,.5); flex: 1; }
/* Margem lines */
.lp-margem-line { position: absolute; background: rgba(220,100,100,.7); }
.lp-margem-line--top, .lp-margem-line--bottom { left: 0; right: 0; height: 2px; }
.lp-margem-line--left, .lp-margem-line--right { top: 0; bottom: 0; width: 2px; }
.lp-margem-line--top    { top: 10%; }
.lp-margem-line--bottom { bottom: 10%; }
.lp-margem-line--left   { left: 10%; }
.lp-margem-line--right  { right: 10%; }
/* Sangria */
.lp-sangria-line { position: absolute; background: rgba(255,80,80,.5); }
.lp-sangria-line--top, .lp-sangria-line--bottom { left: 0; right: 0; height: 1.5px; }
.lp-sangria-line--left, .lp-sangria-line--right { top: 0; bottom: 0; width: 1.5px; }
.lp-sangria-line--top    { top: 5%; }
.lp-sangria-line--bottom { bottom: 5%; }
.lp-sangria-line--left   { left: 5%; }
.lp-sangria-line--right  { right: 5%; }

/* Legend */
.lp-vis-legend { position: absolute; bottom: 16px; right: 16px; background: rgba(255,255,255,.93); border-radius: 8px; padding: 10px 14px; box-shadow: var(--lp-shadow); font-size: 12px; }
.lp-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.lp-legend-swatch { width: 28px; height: 10px; border-radius: 2px; }
.lp-swatch--cut   { background: transparent; border: 2px dashed #e53935; }
.lp-swatch--fold  { background: transparent; border: 2px dashed #2196f3; }
.lp-swatch--safe  { background: rgba(220,100,100,.55); }
.lp-swatch--cover { background: rgba(100,140,255,.5); }
.lp-swatch--spine { background: rgba(60,200,100,.7); }
.lp-swatch--flap  { background: rgba(255,230,80,.6); }

/* Hint */
.lp-vis-hint { position: absolute; bottom: 16px; left: 16px; max-width: 420px; background: rgba(255,255,255,.93); border-left: 4px solid var(--lp-primary); border-radius: 6px; padding: 10px 14px; font-size: 12px; color: var(--lp-primary); box-shadow: var(--lp-shadow); }

/* ── Step actions bar ───────────────────────────────────── */
.lp-step__actions { display: flex; justify-content: space-between; align-items: center; margin-top: 36px; }
.lp-step__actions--vis { padding: 12px 20px; background: var(--lp-card); border-top: 1px solid var(--lp-border); }

/* ── 360° Book Preview ──────────────────────────────────── */
.lp-preview3d-wrap {
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: var(--lp-radius);
  overflow: hidden;
  padding: 32px 20px 20px;
}

/* Stage: perspective container */
.lp-360-stage {
  perspective: 1100px;
  perspective-origin: 50% 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

/* Scene: holds the rotating book */
.lp-360-scene {
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Book: CSS 3D cuboid — dimensions set by JS */
.lp-360-book {
  position: relative;
  transform-style: preserve-3d;
  /* transitions handled by JS rAF loop */
}

/* Each face — base rules; geometry injected by JS via <style id="lp-face-style"> */
.lp-face {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* Front face: full cover image cropped to right half */
.lp-face--front {
  background: #111;
  box-shadow: 4px 0 20px rgba(0,0,0,.6);
}
.lp-face--front img {
  position: absolute; top: 0; left: 0;
  width: 200%; height: 100%;
  object-fit: cover;
  object-position: right center;
  pointer-events: none;
}

/* Back face: full cover image cropped to left half */
.lp-face--back {
  background: #111;
  box-shadow: -4px 0 20px rgba(0,0,0,.6);
}
.lp-face--back img {
  position: absolute; top: 0; left: 0;
  width: 200%; height: 100%;
  object-fit: cover;
  object-position: left center;
  pointer-events: none;
}

/* Spine */
.lp-face--left  { box-shadow: inset -3px 0 8px rgba(0,0,0,.5); }
.lp-spine-gradient { width: 100%; height: 100%; background: linear-gradient(to right,#1a1a2e,#2d2d6b,#1a1a2e); }

/* Pages (right edge) */
.lp-face--right { background: #f0e8d8; }
.lp-pages-texture {
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    #e8dfc8 0px, #e8dfc8 1px,
    #f5edd8 1px, #f5edd8 3px
  );
}

/* Top / Bottom edges */
.lp-face--top    { background: #e8dfc8; }
.lp-face--bottom { background: #ddd5c0; }

/* Barcode placeholder on back face */
.lp-barcode-placeholder {
  position: absolute; bottom: 16px; right: 12px;
  background: #fff; padding: 7px 10px; border-radius: 4px;
  text-align: center; font-size: 9px; color: #333; line-height: 1.5;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  z-index: 2;
}
.lp-barcode-lines {
  height: 28px; margin-top: 4px;
  background: repeating-linear-gradient(to right,#000 0,#000 2px,#fff 2px,#fff 4px);
}

/* Ground shadow */
.lp-360-shadow {
  position: absolute;
  bottom: -10px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 30px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.55) 0%, transparent 70%);
  pointer-events: none;
}

/* Drag hint */
.lp-360-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.75);
  font-size: 12px; padding: 4px 14px; border-radius: 20px;
  pointer-events: none; white-space: nowrap;
  animation: lp-hint-fade 3s ease 2s forwards;
}
@keyframes lp-hint-fade { to { opacity: 0; } }

/* Angle buttons row */
.lp-360-buttons {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 10px;
  margin-top: 20px;
}
.lp-angle-btn {
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25); border-radius: 24px;
  padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .18s, border-color .18s;
}
.lp-angle-btn:hover   { background: rgba(255,255,255,.22); }
.lp-angle-btn.active  { background: var(--lp-primary); border-color: var(--lp-primary); }
.lp-angle-btn--auto   { background: rgba(67,160,71,.3); border-color: rgba(67,160,71,.6); }
.lp-angle-btn--auto.active { background: var(--lp-success); border-color: var(--lp-success); }

/* Orelha toggle row */
.lp-360-orelha-row {
  display: flex; justify-content: center;
  margin-top: 14px;
}

/* ── Success ─────────────────────────────────────────────── */
.lp-step--success { text-align: center; padding: 80px 40px; }
.lp-success-icon { font-size: 72px; margin-bottom: 20px; }
.lp-step--success h2 { font-size: 26px; font-weight: 700; color: var(--lp-success); margin-bottom: 12px; }
.lp-step--success p { color: var(--lp-muted); margin-bottom: 30px; }

/* ── Loading overlay ────────────────────────────────────── */
.lp-loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 999; backdrop-filter: blur(2px); }
.lp-spinner { width: 46px; height: 46px; border: 4px solid var(--lp-border); border-top-color: var(--lp-primary); border-radius: 50%; animation: lp-spin .8s linear infinite; }
@keyframes lp-spin { to { transform: rotate(360deg); } }
#lp-loading-msg { color: var(--lp-muted); font-size: 14px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .lp-step { padding: 24px 16px; }
  .lp-step2-layout { grid-template-columns: 1fr; }
  .lp-progress { padding: 14px 16px; overflow-x: auto; }
  .lp-visualizer-toolbar { gap: 12px; padding: 8px 10px; }
  .lp-range--sm { width: 70px; }
  .lp-360-stage { min-height: 280px; perspective: 700px; }
  .lp-360-buttons { gap: 7px; }
  .lp-angle-btn { padding: 6px 12px; font-size: 12px; }
}
