/* 기본 스타일 */
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  overflow: auto;
}

/* 레이아웃 컨테이너 */
.container {
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 헤더 영역 */
.header {
  background-color: #2c3e50;
  color: white;
  padding: 10px 20px;
  border-radius: 5px 5px 0 0;
  margin-bottom: 20px;
}

.header h1 {
  margin: 0;
  font-size: 24px;
}

/* 콘텐츠 영역 */
.content {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

/* 맵 섹션 */
.map-section {
  width: 100%;
  aspect-ratio: 1;
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* 패널 공통 스타일 */
.control-panel,
.status-panel {
  flex: 1;
  min-width: 300px;
  width: 100%;
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin-bottom: 20px;
}

.panel-section {
  margin-bottom: 20px;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

.panel-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.panel-section h3,
.status-panel h3 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 18px;
}

.control-group {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#statusInfo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

/* 로그 및 메시지 영역 */
.log-area,
.message-area {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  font-family: monospace;
  height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* 버튼 스타일 */
.btn {
  padding: 8px 12px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: #2980b9;
}

.btn.active {
  background-color: #e74c3c;
}

/* 입력 필드 스타일 */
input[type="file"],
input[type="number"],
select {
  padding: 6px 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 14px;
}

input[type="number"] {
  width: 80px;
}

label {
  font-size: 14px;
  margin-right: 5px;
}

/* 맵 컨테이너 */
#mapContainer {
  width: 70%;
  height: 70%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 3px solid #333;
  box-sizing: border-box;
  overflow: hidden;
  transform: rotate(45deg);
}

/* 그리드 */
#grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  grid-template-rows: repeat(14, 1fr);
  gap: 0;
  position: relative;
  transform: rotate(180deg);
  box-sizing: border-box;
}

.grid-cell {
  width: 100%;
  height: 100%;
  border: 1px solid #ccc;
  background-color: white;
  box-sizing: border-box;
}

/* 교차점: 타일 모서리에 나타나는 작은 검정 점 */
.terrain {
  width: calc(8px + 0.6vw);
  height: calc(8px + 0.6vw);
  background-color: transparent;
  border: 1px solid black;
  border-radius: 50%;
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  will-change: transform, left, top; /* 성능 최적화를 위한 will-change 추가 */
}

/* 이동할 동그라미 */
#circle {
  width: 20px;
  height: 20px;
  background-color: rgb(255, 0, 0);
  border-radius: 50%;
  position: absolute;
  transition: all 0.3s;
}

/* 툴크 */
#tooltip {
  white-space: pre-line;
  position: absolute;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1000;
  pointer-events: none;
}

/* 객체 스타일 */
.object {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  z-index: 10;
  border: 1px solid rgba(0, 0, 0, 0.3);
  transition: width 0.2s, height 0.2s, left 0.2s, top 0.2s;
  box-sizing: border-box;
  will-change: transform, width, height, left, top; /* 성능 최적화를 위한 will-change 추가 */
}

.object.selected {
  border: 2px solid #3498db;
  z-index: 20;
  box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

/* 채팅 로그 아이콘 */
.chat-log-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #4CAF50;
  color: white;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 10;
}

.chat-log-btn:hover {
  background-color: #45a049;
}

.chat-icon {
  font-size: 20px;
}

/* 아이콘 컨테이너 */
.icon-container {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

/* 왼쪽 아이콘 컨테이너 */
.icon-container-left {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

/* 오른쪽 아이콘 컨테이너 */
.icon-container-right {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

/* 아이콘 버튼 스타일 */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #3498db;
  color: white;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background-color: #2980b9;
  transform: scale(1.05);
}

.icon-btn .icon {
  font-size: 20px;
}

/* 모달 컨테이너 (기존 chat-log-container를 대체) */
.modal-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 800px;
  height: 70%;
  max-height: 600px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-container.show {
  opacity: 1;
  visibility: visible;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
  background-color: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
}

.close-btn:hover {
  color: #000;
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 0 0 8px 8px;
}

/* 인벤토리 테이블 스타일 */
.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.inventory-table th, .inventory-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.inventory-table th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #333;
}

.inventory-table tr:hover {
  background-color: #f5f5f5;
  cursor: pointer;
}

.empty-inventory {
  text-align: center;
  color: #666;
  padding: 30px;
}

/* 기존 chat-log 관련 클래스를 유지하되 필요한 부분 수정 */
.chat-log-item {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  background-color: #f8f9fa;
  font-family: 'Consolas', monospace;
  line-height: 1.4;
  word-break: break-all;
}

.chat-log-item.system {
  background-color: #e8f4f8;
  color: #0066cc;
}

.chat-log-item.whisper {
  background-color: #f8e8f8;
  color: #993399;
}

.chat-log-item.shout {
  background-color: #ffe8e8;
  color: #cc3300;
}

.empty-log {
  text-align: center;
  color: #666;
  padding: 30px;
}

/* 채팅 기록 스타일 */
.chat-history {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  background-color: #f9f9f9;
}

.chat-item {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 5px;
  line-height: 1.4;
  word-break: break-word;
  background-color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-item:last-child {
  margin-bottom: 0;
}

.chat-item.system {
  background-color: #f0f0f0;
  color: #666;
}

.chat-item.whisper {
  background-color: #e6f7ff;
  color: #0066cc;
}

.chat-item.shout {
  background-color: #fff0f0;
  color: #cc0000;
}

/* 반응형 레이아웃 */
@media (min-width: 1200px) {
  .terrain {
    width: calc(10px + 0.8vw);
    height: calc(10px + 0.8vw);
  }
}

@media (max-width: 768px) {
  .content {
    flex-direction: column;
  }
  
  .map-section {
    padding: 15px;
  }
  
  .terrain {
    width: calc(7px + 0.5vw);
    height: calc(7px + 0.5vw);
  }
  
  .chat-log-container {
    width: 90%;
    height: 80%;
  }

  /* 모바일 환경에서의 입력 필드 최적화 */
  input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    font-size: 13px;
  }

  select {
    max-width: 120px;
    padding: 4px 6px;
    font-size: 13px;
  }

  .control-group {
    gap: 6px;
  }

  label {
    font-size: 13px;
    margin-right: 3px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  .modal-container {
    width: 95%;
    height: 85%;
  }
}

@media (max-width: 480px) {
  .map-section {
    padding: 10px;
  }
  
  .terrain {
    width: calc(6px + 0.3vw);
    height: calc(6px + 0.3vw);
  }
  
  .chat-log-btn {
    width: 35px;
    height: 35px;
  }
  
  .chat-icon {
    font-size: 16px;
  }

  input[type="number"] {
    width: 50px;
    padding: 3px 5px;
    font-size: 12px;
  }

  select {
    max-width: 100px;
    padding: 3px 5px;
    font-size: 12px;
  }

  .control-group {
    gap: 4px;
  }

  label {
    font-size: 12px;
    margin-right: 2px;
  }

  .btn {
    padding: 5px 8px;
    font-size: 12px;
  }

  .modal-container {
    width: 98%;
    height: 90%;
  }
}

/* 채팅 입력 패널 */
.chat-input-panel {
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin-top: 20px;
}

.chat-type-selector {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-type-selector label {
  padding: 5px 10px;
  background-color: #f8f9fa;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-input-container {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

#chatInput {
  flex: 1;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
}

#recipientInput {
  width: 120px;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
}

.chat-history {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 10px;
  background-color: #f8f9fa;
}

.chat-item {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 4px;
  background-color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-item.system {
  background-color: #f0f0f0;
  color: #666;
}

.chat-item.whisper {
  background-color: #e6f7ff;
  color: #0066cc;
}

.chat-item.shout {
  background-color: #fff0f0;
  color: #cc0000;
}

/* 반응형 스타일 */
@media (max-width: 768px) {
  .chat-type-selector {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .chat-input-container {
    flex-wrap: wrap;
  }
  
  #recipientInput {
    width: 100%;
  }
}

/* 인벤토리 관리 UI */
.inventory-manager {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-form {
  background-color: #f8f9fa;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
}

.item-form h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #333;
  font-size: 16px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row input,
.form-row select {
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
}

.form-row input[type="number"] {
  width: 80px;
  flex: 0 0 80px;
}

.form-row select {
  min-width: 100px;
  flex: 0 0 100px;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.btn-danger {
  background-color: #dc3545;
}

.btn-danger:hover {
  background-color: #c82333;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
}

.inventory-table-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.inventory-table th, 
.inventory-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.inventory-table th {
  position: sticky;
  top: 0;
  background-color: #f8f9fa;
  font-weight: bold;
  color: #333;
  z-index: 1;
}

.inventory-table tr:hover {
  background-color: #f5f5f5;
  cursor: pointer;
}

.inventory-table tr:last-child td {
  border-bottom: none;
}

.action-buttons {
  display: flex;
  gap: 5px;
}

.empty-inventory {
  text-align: center;
  color: #666;
  padding: 30px;
}

/* 모바일 환경에서 인벤토리 테이블 반응형 조정 */
@media (max-width: 768px) {
  .item-form {
    padding: 10px;
  }

  .item-form h4 {
    font-size: 14px;
  }

  .form-row {
    gap: 6px;
  }
  
  .form-row input[type="text"] {
    font-size: 13px;
    padding: 6px 8px;
  }

  .form-row input[type="number"] {
    width: 45px;
    padding: 6px;
    font-size: 13px;
    flex: 0 0 45px;
  }
  
  .form-row select {
    width: 90px;
    min-width: 90px;
    padding: 6px;
    font-size: 13px;
    flex: 0 0 90px;
  }

  .inventory-table th,
  .inventory-table td {
    padding: 8px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .item-form {
    padding: 8px;
  }

  .item-form h4 {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .form-row {
    gap: 4px;
  }

  .form-row input[type="text"] {
    font-size: 12px;
    padding: 4px 6px;
  }

  .form-row input[type="number"] {
    width: 40px;
    padding: 4px;
    font-size: 12px;
    flex: 0 0 40px;
  }
  
  .form-row select {
    width: 80px;
    min-width: 80px;
    padding: 4px;
    font-size: 12px;
    flex: 0 0 80px;
  }

  .btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .inventory-table th,
  .inventory-table td {
    padding: 6px;
    font-size: 12px;
  }

  .button-group {
    gap: 6px;
  }

  .btn-small {
    padding: 3px 6px;
    font-size: 11px;
  }
}

/* 채팅 컨테이너 스타일 */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-log-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 15px;
  border: 1px solid #eee;
}

/* 모달 내 채팅 입력 패널 */
.modal-content .chat-input-panel {
  background-color: #f8f8f8;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
  margin-top: auto;
}

.modal-content .chat-type-selector {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-content .chat-type-selector label {
  padding: 5px 10px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.2s, border-color 0.2s;
}

.modal-content .chat-type-selector label:hover {
  background-color: #f0f0f0;
  border-color: #ccc;
}

.modal-content .chat-type-selector input[type="radio"]:checked + label,
.modal-content .chat-type-selector label:has(input[type="radio"]:checked) {
  background-color: #e8f4fc;
  border-color: #2196f3;
  color: #0c63e4;
}

.modal-content .chat-input-container {
  display: flex;
  gap: 8px;
}

.modal-content #chatInput,
.modal-content #recipientInput {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) inset;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content #chatInput:focus,
.modal-content #recipientInput:focus {
  border-color: #4a9fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 159, 255, 0.15);
}

.modal-content #chatInput {
  flex: 1;
}

.modal-content #recipientInput {
  width: 120px;
}

.modal-content #sendChatBtn {
  padding: 9px 15px;
  background-color: #4a9fff;
  transition: background-color 0.2s;
}

.modal-content #sendChatBtn:hover {
  background-color: #3a8ee6;
}

/* 채팅 로그 아이템 강화 스타일 */
.chat-log-item {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-log-item.system {
  background-color: #eaf6ff;
  border-left: 3px solid #4a9fff;
}

.chat-log-item.whisper {
  background-color: #f5eaff;
  border-left: 3px solid #9c27b0;
}

.chat-log-item.shout {
  background-color: #fff0f0;
  border-left: 3px solid #f44336;
}

/* 모바일 환경을 위한 반응형 조정 */
@media (max-width: 768px) {
  .modal-content .chat-type-selector {
    gap: 4px;
  }
  
  .modal-content .chat-type-selector label {
    padding: 3px 8px;
    font-size: 12px;
  }
  
  .modal-content .chat-input-panel {
    padding: 8px;
  }
  
  .modal-content #chatInput,
  .modal-content #recipientInput {
    padding: 6px 8px;
    font-size: 13px;
  }
  
  .modal-content #sendChatBtn {
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .chat-log-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .modal-content .chat-type-selector {
    gap: 3px;
  }
  
  .modal-content .chat-type-selector label {
    padding: 2px 6px;
    font-size: 11px;
  }
  
  .modal-content .chat-input-panel {
    padding: 6px;
  }
  
  .modal-content #chatInput,
  .modal-content #recipientInput {
    padding: 4px 6px;
    font-size: 12px;
  }
  
  .modal-content #sendChatBtn {
    padding: 4px 8px;
    font-size: 12px;
  }
  
  .chat-log-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.3;
  }
  
  .chat-log-container {
    padding: 8px;
  }
  
  .chat-type-selector input[type="radio"] + label {
    padding: 2px 6px;
    font-size: 11px;
  }
  
  .chat-input-container {
    gap: 4px;
  }
  
  #recipientInput {
    width: 80px;
    min-width: 80px;
  }
}

/* 채팅 타입 선택기 최적화 */
.chat-type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-type-selector input[type="radio"] {
  display: none;
}

.chat-type-selector input[type="radio"] + label {
  padding: 4px 8px;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.chat-type-selector input[type="radio"]:checked + label {
  background-color: #e8f4fc;
  border-color: #2196f3;
  color: #0c63e4;
}

/* 채팅 입력 영역 최적화 */
.chat-input-container {
  display: flex;
  gap: 6px;
  align-items: center;
}

#chatInput {
  flex: 1;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

#recipientInput {
  width: 100px;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

#sendChatBtn {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 4px;
}
