/* ============================================================
   著色模組 — 列印 + 互動樣式
   螢幕模式用 px，列印模式用 mm/pt
   ============================================================ */

/* ----------------------------------------------------------
   互動模式 Layout
   ---------------------------------------------------------- */

/* 主 Layout：左側縮圖欄 + 右側畫布 */
.coloring-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* 左側縮圖欄 */
.coloring-sidebar {
  width: 80px;
  background: #F9FAFB;
  border-right: 1px solid #E5E7EB;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* 縮圖按鈕 */
.coloring-thumb {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: 2px solid #E5E7EB;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 150ms, box-shadow 150ms;
}

/* 選中縮圖 */
.coloring-thumb.active {
  border: 3px solid #EC4899;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.2);
}

/* 右側主區域 */
.coloring-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Canvas 容器 */
.coloring-canvas-wrap {
  flex: 1;
  position: relative;
  touch-action: none;
  overflow: hidden;
}

/* 線稿底圖 */
.coloring-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

/* Canvas 繪製層 */
.coloring-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* 底部工具列 */
.coloring-toolbar {
  flex-shrink: 0;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #FAFAFA;
  flex-wrap: wrap;
}

/* 顏色按鈕 */
.coloring-color-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 150ms ease-out, border-color 150ms;
  flex-shrink: 0;
}

.coloring-color-btn:active {
  transform: scale(0.9);
}

.coloring-color-btn.selected {
  border-color: #1d1d1f;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
  transform: scale(1.1);
}

/* 筆刷粗細按鈕 */
.coloring-brush-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms;
}

.coloring-brush-opt.active {
  background: #FDF2F8;
}

/* 預覽 Modal */
.coloring-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.coloring-preview-card {
  background: white;
  border-radius: 24px;
  padding: 24px;
  max-width: 80vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 清除按鈕 */
.coloring-clear-btn {
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid #E5E7EB;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: #6B7280;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms;
}

.coloring-clear-btn:active {
  background: #F3F4F6;
}

/* ----------------------------------------------------------
   列印模式（保留原有列印樣式）
   ---------------------------------------------------------- */

/* 列印排版：線稿 + 指定色面板並排 */
.coloring-lineart {
  flex: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.coloring-lineart-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.coloring-color-panel {
  flex: 2;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 200px;
}

.coloring-color-dot {
  display: flex;
  align-items: center;
}

.coloring-dot-svg {
  width: 60px;
  height: 30px;
}

@media print {
  /* 互動元素列印時隱藏 */
  .coloring-sidebar,
  .coloring-toolbar,
  .coloring-preview-modal {
    display: none !important;
  }

  .coloring-lineart-img {
    max-height: 170mm;
  }

  .coloring-color-panel {
    gap: 8mm;
    min-height: 60mm;
  }

  .coloring-dot-svg {
    width: 18mm;
    height: 9mm;
  }
}
