/* =====================================================
   gridstack-editor.css
   자리 배치 템플릿 그리드 에디터 스타일
   ===================================================== */

/* ── 범례 ─────────────────────────────────────────────── */
.grid-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 22px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid;
  flex-shrink: 0;
}
.legend-dot.empty        { background:#f3f4f6; border-color:#d1d5db; }
.legend-dot.individual   { background:#dbeafe; border-color:#93c5fd; }
.legend-dot.couple       { background:#d1fae5; border-color:#6ee7b7; }
.legend-dot.couple-wide  { background:#a7f3d0; border-color:#34d399; width:44px; }

/* ── 툴바 ─────────────────────────────────────────────── */
.editor-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.editor-toolbar .toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: var(--transition);
  user-select: none;
}
.tool-btn:hover  { background:var(--bg-elevated); color:var(--text-primary); }
.tool-btn.active { border-color:var(--accent); background:var(--accent-light); color:var(--accent); }
.tool-btn.danger { border-color:var(--danger); color:var(--danger); background:var(--danger-light); }

/* ── 그리드 사이즈 입력 ───────────────────────────────── */
.grid-size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.grid-size-row input[type="number"] {
  width: 72px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
  background: var(--bg-surface);
  color: var(--text-primary);
}
.grid-size-row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* ── 자동번호 입력 바 ─────────────────────────────────── */
.auto-number-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.auto-number-bar input[type="number"] {
  width: 80px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
  background: var(--bg-surface);
  color: var(--text-primary);
}
.auto-number-bar select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ── 그리드 래퍼 ─────────────────────────────────────── */
.grid-editor-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  padding: 6px;
}

/* ── 그리드 테이블 ───────────────────────────────────── */
.grid-table {
  border-collapse: collapse;
  table-layout: fixed;
}
.grid-table th.row-num {
  width: 25px;
  min-width: 25px;
  max-width: 25px;
  height: 25px;
  min-height: 25px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  text-align: center;
  border: 1px solid var(--border);
  padding: 0;
  user-select: none;
  box-sizing: border-box;
}
.grid-table .col-num {
  height: 25px;
  min-height: 25px;
  max-height: 25px;
  min-width: 68px;
  width: 68px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0;
  user-select: none;
  box-sizing: border-box;
}

/* ── 셀 ──────────────────────────────────────────────── */
.grid-table td.g-cell {
  width: 68px;
  min-width: 68px;
  height: 52px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  text-align: center;
  transition: filter 0.1s ease;
  user-select: none;
}
.grid-table td.g-cell:hover { filter: brightness(0.92); }
.grid-table td.g-cell.g-cell-gap {
  background: #f9fafb;
  border-color: #e5e7eb;
  cursor: default;
}
.grid-table td.g-cell.g-cell-gap:hover {
  filter: none;
}

/* 타입별 배경 */
.g-cell[data-type="empty"]       { background:#f9fafb; }
.g-cell[data-type="individual"]  { background:#dbeafe; border-color:#93c5fd; }
.g-cell[data-type="couple"]      { background:#d1fae5; border-color:#6ee7b7; }
.g-cell[data-type="couple-wide"] { background:#a7f3d0; border-color:#34d399; }

/* 타입 배지 (좌상단 아이콘) */
.g-cell .type-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.g-cell[data-type="individual"]  .type-badge { color:#1d4ed8; }
.g-cell[data-type="couple"]      .type-badge { color:#059669; }
.g-cell[data-type="couple-wide"] .type-badge { color:#047857; }

.tpl-preview-gap {
  background:#f8fafc !important;
  border-color:#e5e7eb !important;
}

/* 셀 라벨 인풋 */
.g-cell .cell-input {
  display: block;
  width: 100%;
  height: 100%;
  padding: 4px 6px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  cursor: text;
}
.g-cell[data-type="empty"] .cell-input {
  pointer-events: none;
}

/* couple-wide 셀은 두 칸 너비 */
.g-cell[data-type="couple-wide"] {
  min-width: 100px;
}

/* ── 미리보기 (목록 카드용) ──────────────────────────── */
.tpl-preview {
  display: inline-block;
  font-size: 0;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  padding: 2px;
}
.tpl-preview-row { display: block; }
.tpl-preview-cell {
  display: inline-block;
  width: 7px;
  height: 5px;
  border: 0.5px solid #e5e7eb;
  background: #f9fafb;
}
.tpl-preview-cell.individual  { background:#bfdbfe; border-color:#93c5fd; }
.tpl-preview-cell.couple      { background:#a7f3d0; border-color:#6ee7b7; }
.tpl-preview-cell.couple-wide { background:#6ee7b7; border-color:#34d399; width:14px; }

/* ── 풀스크린 에디터 모달 ────────────────────────────── */
.modal-editor {
  width: 77vw;
  max-width: 77vw;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.modal-editor .modal-header { flex-shrink: 0; }
.modal-editor .modal-title { font-size: 22px; }
.modal-editor .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px;
}
.modal-editor .modal-footer { flex-shrink: 0; }

/* ── 힌트 텍스트 ─────────────────────────────────────── */
.editor-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── 구역(섹션) 카드 ─────────────────────────────────── */
.section-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: var(--bg-surface);
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.section-name-input {
  flex: 1;
  min-width: 120px;
  max-width: 240px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-surface);
  color: var(--text-primary);
}
.section-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.section-body { padding: 10px; }
.section-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.section-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ── 잠금 셀 (계약 중) ───────────────────────────────────
   빨강 도배 방지: 네온 테두리 대신 옅은 점유 톤 + 가는 테두리.
   상태는 작은 "계약" 배지로 전달. */
.g-cell.g-cell-locked {
  border: 1px solid #ef4444 !important;          /* 얇은 빨간 테두리 (이전 2px → 1px) */
  box-shadow: inset 0 0 0 999px rgba(71,85,105,0.04); /* 아주 옅은 점유감 */
  cursor: not-allowed;
}
.g-cell.g-cell-locked:hover { filter: none; }
/* 자물쇠 아이콘 — 우상단 작게 (계약 잠금 표시) */
.g-cell .cell-lock-icon {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 9px;
  color: #ef4444;
  pointer-events: none;
  opacity: 0.8;
}
/* 계약 셀 "계약" 배지 — 작고 차분한 로즈 핀 (셀 하단 중앙) */
.g-cell .cell-lock-tag {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
  background: rgba(176,106,106,0.88);
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0.95;
}

/* ── 툴바 타입별 색상 점 ─────────────────────────────── */
.type-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
}
