/* === Settings Styles === */
/**
 * @fileoverview 설정 패널(#setting-box), 상차림 미리보기, 슬롯 버튼, 설정 테이블 및 유틸리티 스타일
 */
/* 오른쪽 서랍(대국·설정). 위치·크기·고정·여닫기 애니메이션과 레일은 css/drawer.css */
#setting-box {
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  color: var(--color-text-primary, #f8fafc);
  padding: 0;
  font-size: 13px;
}

/* 설정·기보 패널 공용 머리/본문 */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  position: relative;
  background: rgba(15, 23, 42, 0.2);
}

.settings-title {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--color-text-primary, #f8fafc);
  letter-spacing: 0.5px;
}

.settings-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
}

#setting-box .settings-header {
  justify-content: flex-start;
  gap: 8px;
  height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
}

#setting-box .settings-title {
  font-size: 15px;
  font-weight: 800;
}

#setting-box .settings-scroll-area {
  padding: 12px 14px;
}

#close-btn {
  position: static;
  transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

#close-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

#setting-box .start-settings-btn {
  position: static;
  transform: none;
  margin-left: auto;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

#setting-box .start-settings-btn:active {
  transform: scale(0.95);
}

#setting-box .setting-category {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
}

#setting-box .category-header {
  height: 30px;
  margin-bottom: 8px;
}

#setting-box .category-title {
  font-size: 14px;
  font-weight: 800;
}

/* 재시작: 상차림 버튼을 2×2로 접는다 */
#setting-box .charim-container {
  gap: 0;
}

#setting-box .charim-table-wrapper {
  min-width: 0;
}

#setting-box .charim-table-wrapper tr:not(:first-child) td:nth-child(2) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

#setting-box .charim-table-wrapper button.charim0,
#setting-box .charim-table-wrapper button.charim1 {
  margin: 0;
  padding: 6px 4px;
  font-size: 12px;
}

#setting-box .charim-preview-container {
  margin-top: 10px;
  padding: 10px 8px;
  gap: 8px;
}

#setting-box .charim-preview-tokens {
  gap: 3px;
}

#setting-box .preview-token {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

#setting-box .preview-token-empty {
  width: 22px;
  height: 22px;
}

#setting-box .restart-options {
  margin-top: 8px;
}

.restart-btn {
  width: 100%;
  min-height: 36px;
  margin-top: 8px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.restart-btn:hover {
  background: var(--color-primary-dark);
}

#setting-box .settings-table td {
  font-size: 12.5px;
  padding: 6px 2px;
}

#setting-box .section-divider-cell {
  padding-top: 14px;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

#setting-box .range-slider {
  width: 90px;
}

.setting-category {
  margin-bottom: 25px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 20px;
}

.setting-category h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--color-primary, #3b82f6);
  border-bottom: 1.5px solid rgba(59, 130, 246, 0.3);
  padding-bottom: 6px;
}

.charim-container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.charim-table-wrapper {
  flex: 1;
  min-width: 300px;
}

.charim-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.charim-table-wrapper td {
  padding: 6px 4px;
  vertical-align: middle;
  text-align: center;
  font-size: 0.9em;
}

.charim-table-wrapper button.charim0,
.charim-table-wrapper button.charim1 {
  background-color: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 8px;
  margin: 2px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.charim-table-wrapper button.charim0:hover,
.charim-table-wrapper button.charim1:hover {
  border-color: rgba(59, 130, 246, 0.6);
}

.charim-btn-wrapper {
  display: flex;
  align-items: stretch;
}

.charim-btn-wrapper button {
  height: 100%;
  padding: 0 30px;
  font-size: 1.15em;
  font-weight: 700;
  background-color: var(--color-primary, #3b82f6);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
  transition: all 0.2s;
  min-width: 120px;
}

.charim-btn-wrapper button:hover {
  background-color: var(--color-primary-dark, #2563eb);
  box-shadow: 0 6px 8px rgba(37, 99, 235, 0.4);
}

/* 상차림 배치 예시 그림(미니어처 토큰) 스타일 */
.charim-preview-container {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 15px 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.charim-preview-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.charim-preview-label {
  font-size: 0.9em;
  color: #94a3b8;
  min-width: 110px;
  font-weight: bold;
}

.charim-preview-tokens {
  display: flex;
  gap: 6px;
}

.preview-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.preview-token-han {
  background: #991b1b;
  color: #fca5a5;
  border: 1.5px solid #ef4444;
}

.preview-token-cho {
  background: #1e3a8a;
  color: #93c5fd;
  border: 1.5px solid #3b82f6;
}

.preview-token-neutral {
  background: #334155;
  color: #94a3b8;
  border: 1.5px solid #475569;
  opacity: 0.7;
}

.preview-token-empty {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
}

/* 설정 테이블 및 폼 컨트롤 스타일 */
.settings-table {
  width: 100%;
  border-collapse: collapse;
}

.settings-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-table tr:last-child {
  border-bottom: none;
}

.settings-table td {
  padding: 8px 4px;
  vertical-align: middle;
  font-size: 0.92em;
}

.settings-table td:first-child {
  text-align: left;
  color: #cbd5e1;
  font-weight: 500;
}

.settings-table td:last-child {
  text-align: right;
}

.settings-table button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #f8fafc;
  padding: 4px 10px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.settings-table button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.settings-table button:active {
  transform: scale(0.95);
}

.settings-table select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #f8fafc;
  padding: 5px 10px;
  font-size: 0.9em;
  cursor: pointer;
  outline: none;
}

.settings-table select:focus {
  border-color: var(--color-primary, #3b82f6);
}

.settings-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #f8fafc;
  padding: 6px 10px;
  font-size: 0.9em;
  text-align: left;
  outline: none;
  transition: border-color 0.2s;
}

.settings-input:focus {
  border-color: var(--color-primary, #3b82f6);
}

/* Slots, Reset, Copy and Settings Start Button Styles */
.start-settings-btn {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-primary, #3b82f6);
  border: none;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.2s, transform 0.1s;
}

.start-settings-btn:hover {
  background: var(--color-primary-dark, #2563eb);
}

.start-settings-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
  height: 32px;
  box-sizing: border-box;
}

.category-header.accordion-toggle {
  cursor: pointer;
  user-select: none;
}

.category-title {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--color-text-primary, #f8fafc);
}

.category-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.reset-category-btn,
.copy-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
  transition: color 0.2s, transform 0.1s;
}

.reset-category-btn:hover,
.copy-btn:hover {
  color: #cbd5e1;
}

.reset-category-btn:active,
.copy-btn:active {
  transform: scale(0.9);
}

.slot-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.8em;
  font-weight: 700;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.2s;
}

.slot-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
}

.slot-btn.active {
  background: var(--color-primary, #3b82f6);
  border-color: var(--color-primary, #3b82f6);
  color: white;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* === Settings Utility Classes (replacing inline styles) === */
.settings-flex-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.settings-flex-row-gap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.settings-header-actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-input {
  display: none;
  vertical-align: middle;
  margin-left: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.modal-color-picker {
  width: 35px;
  height: 25px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.modal-range-slider {
  width: 100px;
  accent-color: var(--color-primary, #3b82f6);
}

.modal-range-value {
  font-size: 13px;
  min-width: 30px;
  text-align: right;
  color: var(--color-primary, #3b82f6);
}

.range-slider-input {
  width: 150px;
  accent-color: var(--color-primary, #3b82f6);
}

.range-value-display {
  min-width: 45px;
  text-align: right;
  color: var(--color-primary, #3b82f6);
}

.accordion-arrow {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.45);
  margin-left: 2px;
  transition: transform 0.2s;
}

.accordion-arrow .ico {
  width: 16px;
  height: 16px;
}

.accordion-content {
  display: none;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
}

.nation-toggle-btn {
  font-weight: bold;
  border: none;
  border-radius: 6px;
  padding: 6px 15px;
  cursor: pointer;
}

.settings-checkbox {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary, #3b82f6);
}

.settings-section-label {
  font-weight: bold;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85em;
  text-align: left;
}

.charim-table-header {
  text-align: center;
  font-weight: bold;
}

.metadata-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 설정 패널 맨 아래 버전 표시 (module/version.js) */
.app-version-label {
  padding: 12px 0 4px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
  user-select: text;
}

/* 재시작: AI 엔진 상태 (module/engine-fsf.js) */
.ai-engine-status {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--color-text-secondary);
  text-align: left;
}

.ai-engine-status[data-state="ready"] { color: #86efac; }
.ai-engine-status[data-state="loading"] { color: #fcd34d; }
.ai-engine-status[data-state="unavailable"] { color: #fca5a5; }

/* 설정 맨 아래 엔진 라이선스 표시 */
.app-license-label {
  padding: 0 0 8px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

.app-license-label a {
  color: #94a3b8;
}

/* 대국 규칙 (game-rules.js): 체크 상자 여러 개를 줄바꿈해 오른쪽 정렬 */
.rule-options .rule-checks {
  flex-wrap: wrap;
  gap: 4px 10px;
}

.rule-options .rule-checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.rule-options .rule-checks input:disabled + * ,
.rule-options .rule-checks label:has(input:disabled) {
  opacity: 0.5;
}

.rule-options td:first-child {
  white-space: nowrap;
}
