/* --- 변수 및 기본 스타일 --- */
:root {
  --primary-color: #007bff;
  --primary-hover-color: #0056b3;
  --background-color: #f8f9fa;
  --card-background-color: #ffffff;
  --text-color: #343a40;
  --light-text-color: #6c757d;
  --border-color: #dee2e6;
  --shadow-color: rgba(0, 0, 0, 0.05);
  --highlight-color: #e63946;
}

body,
html {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  max-width: 1000px;
  margin: 20px auto;
  padding: 15px;
}

/* 계산기 섹션 */
.calculator-section {
  background-color: var(--card-background-color);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px var(--shadow-color);
}

.calc-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--primary-color);
}

.calc-header p {
  font-size: 14px;
  margin: 0 0 16px 0;
  color: var(--light-text-color);
}

.search-area {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}


.select2-custom-option {
  display: flex;
  align-items: center;
}



#character-name {
  flex-grow: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 15px;
  transition: box-shadow 0.2s;
}

#character-name:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

#search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background-color: var(--primary-color);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: background-color 0.2s;
}

#search-btn:hover {
  background-color: var(--primary-hover-color);
}

.status-config {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.status-input-group {
  display: flex;
  flex-direction: column;
}

.status-input-group label {
  font-size: 12px;
  color: var(--light-text-color);
  margin-bottom: 4px;
}

.status-input-group input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  text-align: center;
  font-size: 14px;
}

.status-input-group select {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background-color: white;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}


.autocomplete-wrapper {
  position: relative;
  flex-grow: 1;
}

.autocomplete-items {
  display: none;
  position: absolute;
  border: 1px solid var(--border-color);
  border-top: none;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background-color: var(--card-background-color);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 16px var(--shadow-color);
}

.autocomplete-items div {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f1;
  font-size: 14px;
}

.autocomplete-items div:last-child {
  border-bottom: none;
}

.autocomplete-items div:hover {
  background-color: #e9e9e9;
}

.autocomplete-items strong {
  color: var(--primary-color);
}

.result-area {
  background-color: #f1f5f9;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
}

.result-area .error {
  color: var(--highlight-color);
  font-weight: 500;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.result-item span:first-child {
  color: var(--light-text-color);
}

.result-item .highlight {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 15px;
}

/* --- 아이템 그리드 --- */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 5px;
}

.item-card {
  background: var(--card-background-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  padding: 3px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  position: relative;
  cursor: grab;
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.image-container {
  position: relative;
  width: 90%;
  aspect-ratio: 1 / 1;
}

.image-container img:not(.emotion-icon) {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.emotion-icon {
  position: absolute;
  top: -1%;
  right: -1%;
  width: 30%;
  height: 30%;
  z-index: 2;
  pointer-events: none;
  background: none;
  border-radius: 0;
}

.quantity-input {
  width: 90%;
  display: flex;
  justify-content: center;
}

.quantity-input input {
  width: 80%;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 0;
  font-size: 12px;
  font-weight: bold;
  -moz-appearance: textfield;
  background-color: transparent;
}

.quantity-input input::-webkit-outer-spin-button,
.quantity-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 드래그 잠금 버튼 스타일 */
#drag-lock-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 1000;
  transition: background-color 0.2s;
  align-items: center;
  justify-content: center;
}

#drag-lock-btn:hover {
  background-color: var(--primary-hover-color);
}

#drag-lock-btn.locked .unlock-icon,
#drag-lock-btn:not(.locked) .lock-icon {
  display: none;
}

#drag-lock-btn svg {
  width: 24px;
  height: 24px;
}

/* 모바일 반응형 */
@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  .calculator-section {
    padding: 16px;
    margin-bottom: 16px;
  }

  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(61px, 1fr));
    gap: 2px;
  }

  #drag-lock-btn {
    display: flex;
  }
}

/* 드래그 앤 드롭 스타일 */
.sortable-ghost {
  opacity: 0.4;
  background: #c8ebfb;
  border: 1px dashed var(--primary-color);
}

.item-card:active {
  cursor: grabbing;
}


/* --- 기동석 조합 카드 --- */
.combination-card {
  background: #e9ecef;
  border-radius: 6px;
  border: 1px solid #ced4da;
  padding: 8px 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  grid-column: span 2;
  /* 2칸 차지 */
}

.combination-card label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-color);
}

.combo-input-group {
  display: flex;
  gap: 4px;
  width: 90%;
}

.combination-card input {
  flex-grow: 1;
  width: 50px;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 0;
  font-size: 13px;
  -moz-appearance: textfield;
}

.combination-card input::-webkit-outer-spin-button,
.combination-card input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.combination-card button {
  padding: 4px 8px;
  border: none;
  background-color: var(--primary-color);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s;
}

.combination-card button:hover {
  background-color: var(--primary-hover-color);
}

.combination-card p {
  font-size: 10px;
  color: var(--light-text-color);
  margin: 0;
  text-align: center;
}

@media (max-width: 600px) {
  .combination-card {
    grid-column: span 3;
    /* 모바일에서는 3칸 차지 */
  }
}