﻿/* ========================================
   BrickRoom 3D — 모바일 전용 CSS
   (max-width: 620px 에서만 적용)
   ======================================== */

* { box-sizing: border-box; }

body {
  overflow: hidden;
  margin: 0;
}

/* ── 전체 레이아웃: 세로 flex ── */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}

/* ── 1. 3D 뷰어 영역 (상단, 최대 공간) ── */
.stage-area {
  order: 1;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 8px 4px;
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar strong {
  font-size: 11px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar span#countText { font-size: 10px; color: var(--muted); white-space: nowrap; }

.topbar-actions { gap: 3px; }
.topbar-actions .language-select { display: none; }
.icon-button { min-width: 40px; min-height: 28px; font-size: 10px; padding: 0 5px; }

.quick-controls { gap: 3px; }
.quick-mode { gap: 2px; }
.transform-mode { min-height: 28px; font-size: 10px; padding: 0 6px; }

.quick-rotate {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
}
.mini-button { min-height: 24px; font-size: 9px; padding: 0; }

.viewport {
  flex: 1;
  min-height: 0;
  outline: none;
  background: #dce4ea;
}

/* ── 2. 제품 목록 패널 (하단 고정) ── */
.left-panel {
  order: 2;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border-top: 2px solid var(--accent);
  padding: 0;
  gap: 0;
  height: 44vh;
  min-height: 120px;
}

/* 드래그 핸들 힌트 */
.left-panel::before {
  content: "";
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 6px auto 2px;
}

/* 브랜드 한 줄 */
.left-panel > .brand {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 2px 12px 4px;
}

.brand-mark { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 5px; }
h1 { font-size: 13px; margin: 0; }
.brand > div > p { display: none; }

/* ⚙️ 장식장 버튼 (모바일 전용) */
.mobile-cabinet-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--button);
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 2px;
}

/* 언어 선택 */
.sidebar-lang-select {
  display: flex;
  margin-left: auto;
}
.sidebar-lang-select select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 5px;
  font-size: 11px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}

/* 제품 섹션 */
.left-panel > .product-section {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  padding: 0 12px 0;
}

.left-panel > .product-section > .section-title-row {
  flex-shrink: 0;
  padding-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.left-panel > .product-section > .section-title-row h2 {
  font-size: 12px;
  margin: 0;
}

/* 제품 목록 세로 스크롤 */
.left-panel > .product-section > #productList {
  position: absolute;
  top: 26px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  padding: 0 4px 8px;
  -webkit-overflow-scrolling: touch;
}

/* 카테고리 헤더 */
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 8px;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.category-header:first-child { margin-top: 0; }
.category-chevron { font-size: 10px; color: var(--muted); }

/* 카테고리 제품: 가로 스크롤 */
.category-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 8px;
  padding: 4px 0 6px;
  -webkit-overflow-scrolling: touch;
}
.category-grid.collapsed { display: none; }

/* 제품 카드 */
.product-card {
  flex: 0 0 88px;
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  cursor: pointer;
  position: relative;
}
.product-thumb {
  display: block;
  width: 60px;
  height: 48px;
  overflow: hidden;
  border-radius: 5px;
  background: #e8eef2;
}
.product-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.product-card strong {
  font-size: 9px;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  display: block;
  overflow: hidden;
  max-height: 2.4em;
}
.product-card small { display: none; }

/* 프리로드 점 */
.preload-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
}
.preload-loading { background: #f59e0b; animation: pulse-dot 1s infinite; }
.preload-cached { background: #22c55e; }
.preload-error { background: #ef4444; }

/* ── 3. 오른쪽 패널: 장식장 설정 오버레이 ── */
.right-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 300;
  background: var(--panel);
  border-top: 2px solid var(--accent);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.right-panel.mobile-open {
  max-height: 75vh;
  overflow-y: auto;
}

/* 장식장 토글 버튼 */
.cabinet-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 1;
}
.cabinet-toggle-arrow { transition: transform 0.2s; font-size: 11px; }
.cabinet-toggle[aria-expanded="true"] .cabinet-toggle-arrow { transform: rotate(180deg); }

/* 장식장 내용 */
.cabinet-body {
  overflow: hidden;
  max-height: 0;
  padding: 0 16px;
  transition: max-height 0.25s ease, padding 0.25s ease;
}
.cabinet-body.open {
  max-height: 600px;
  padding: 12px 16px 20px;
}

.cabinet-checks {
  display: flex;
  gap: 8px;
}
.cabinet-opt-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--button);
  font-size: 12px;
  cursor: pointer;
}

.size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.size-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.size-grid input {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
}

.tool-button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.base-colors {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.base-swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
}
.base-swatch.active { border-color: var(--accent); }

.range-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.range-row input { width: 100%; }

/* 닫기 오버레이 배경 */
.cabinet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0,0,0,0.3);
}
.cabinet-overlay.active { display: block; }
