/* ===================================================================
   bookspice · Card Builder styles
   =================================================================== */

.builder-body { background: var(--bg-2); }

/* 🆕 shelf-select: dropdown เลือกหนังสือจากชั้น */
.shelf-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 6px;
  transition: border-color 0.15s;
}
.shelf-select:hover { border-color: var(--spice); }
.shelf-select:focus {
  outline: none;
  border-color: var(--spice);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.1);
}

.builder-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ========== TOOLS PANEL ========== */
.tools-panel {
  background: var(--bg-3);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 0;
}
.panel-section {
  padding: 18px 20px;
  border-bottom: 1px dashed var(--line);
}
.panel-section h3 {
  font-family: var(--serif);
  font-size: 14px; color: var(--ink-2);
  font-weight: 600; margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.panel-section .field { margin-bottom: 10px; }
.panel-section .field span { font-size: 11px; margin-bottom: 3px; }
.panel-section .field input,
.panel-section .field textarea,
.panel-section .field select {
  font-size: 13px; padding: 8px 12px;
  background: var(--paper);
}

/* template grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.template-thumb {
  aspect-ratio: 4/5;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
  background: var(--bg);
}
.template-thumb:hover { transform: scale(1.05); }
.template-thumb.active {
  border-color: var(--spice);
  box-shadow: 0 0 0 2px rgba(201, 100, 66, 0.2);
}
.template-thumb::after {
  content: attr(data-name);
  position: absolute; bottom: 4px; left: 0; right: 0;
  font-size: 9px; color: var(--ink-3);
  text-align: center; background: rgba(255, 250, 239, 0.8);
  padding: 2px 0;
}
.template-thumb.paper { background: repeating-linear-gradient(45deg, #f5e8d6, #f5e8d6 8px, #ede0c8 8px, #ede0c8 16px); }
.template-thumb.lined { background: linear-gradient(180deg, #fffaef 60%, transparent 60%) 0 0/100% 24px, var(--paper); }
.template-thumb.dots { background: radial-gradient(circle, #d4a373 1.5px, transparent 1.5px) 0 0/12px 12px, var(--paper); }
.template-thumb.warm { background: linear-gradient(135deg, #f4d3b4, #e8a87c); }
.template-thumb.sage { background: linear-gradient(135deg, #c5d5c0, #a8b89a); }
.template-thumb.rose { background: linear-gradient(135deg, #f5c2c7, #d4826e); }
.template-thumb.ink { background: var(--ink-2); }
.template-thumb.ink::after { color: var(--bg-3); background: rgba(0,0,0,0.3); }
.template-thumb.mint { background: linear-gradient(135deg, #d4e4d0, #b8c9b1); }
.template-thumb.gold { background: linear-gradient(135deg, #f0d896, #c89b3c); }

/* rating picker */
.rating-picker { display: flex; gap: 4px; }
.rating-picker button {
  font-size: 22px; padding: 4px;
  filter: grayscale(0.5); opacity: 0.4;
  transition: all 0.15s;
}
.rating-picker button:hover { filter: none; opacity: 1; transform: scale(1.1); }
.rating-picker button.on { filter: none; opacity: 1; }
.hint { font-size: 11px; color: var(--ink-3); display: block; margin-top: 6px; }

/* sticker tabs */
.sticker-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.sticker-tab {
  font-size: 11px; padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-3);
}
.sticker-tab.active { background: var(--spice); color: #fff; border-color: var(--spice); }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.sticker-thumb {
  font-size: 22px;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: grab;
  transition: all 0.15s;
}
.sticker-thumb:hover {
  background: var(--spice);
  transform: scale(1.1);
  border-color: var(--spice);
}

/* ========== CANVAS STAGE ========== */
.canvas-wrap {
  display: flex; flex-direction: column;
  background: var(--bg-2);
  overflow: hidden;
}
.canvas-toolbar {
  padding: 12px 20px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}
.icon-btn:hover { background: var(--spice); color: #fff; border-color: var(--spice); }
.canvas-stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  overflow: auto;
  background:
    radial-gradient(circle at 30% 20%, rgba(201, 100, 66, 0.05), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(122, 140, 110, 0.05), transparent 50%),
    var(--bg-2);
}

.card-canvas {
  width: 420px;
  min-height: 540px;
  background: var(--bg);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(94, 48, 35, 0.08);
  position: relative;
  cursor: default;
}

.canvas-stickers {
  position: absolute; inset: 0;
  pointer-events: none;
}
.placed-sticker {
  position: absolute;
  font-size: 36px;
  pointer-events: auto;
  cursor: move;
  user-select: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  transition: filter 0.1s;
}
.placed-sticker:hover { filter: drop-shadow(0 0 8px rgba(201, 100, 66, 0.5)); }
.placed-sticker.selected { outline: 2px dashed var(--spice); outline-offset: 4px; border-radius: 4px; }

/* ctx menu */
.ctx-menu {
  position: fixed;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 200;
  min-width: 140px;
}
.ctx-menu button {
  display: block; width: 100%;
  padding: 8px 12px; text-align: left;
  font-size: 13px; color: var(--ink-2);
  border-radius: 4px;
}
.ctx-menu button:hover { background: var(--bg-2); }

@media (max-width: 900px) {
  .builder-layout { grid-template-columns: 1fr; height: auto; }
  .tools-panel { max-height: 50vh; }
}
