* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Noto Sans KR', Arial, sans-serif;
  background-color: #f5f5f5;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 헤더 */
.header {
  text-align: center;
  padding: 20px 0;
  background: linear-gradient(135deg, #4A90D9, #357ABD);
  color: white;
  border-radius: 10px 10px 0 0;
  flex-shrink: 0;
}

.header h1 {
  font-size: 24px;
  margin-bottom: 3px;
}

.header p {
  font-size: 13px;
  opacity: 0.9;
}

/* 탭 스타일 */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 2px solid #4A90D9;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 80px;
  padding: 12px 15px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: #e9e9e9;
  font-size: 14px;
  font-weight: bold;
  color: #666;
  transition: all 0.3s;
}

.tab:hover {
  background: #d9d9d9;
}

.tab.active {
  background: #4A90D9;
  color: white;
}

/* 탭 컨텐츠 */
.tab-content {
  display: none;
  background: white;
  padding: 20px;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-content.active {
  display: flex;
}

/* 서브 탭 */
.settings-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sub-tabs {
  display: flex;
  border-bottom: 2px solid #ddd;
  margin-bottom: 15px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.sub-tab {
  padding: 8px 20px;
  cursor: pointer;
  border: none;
  background: #f0f0f0;
  font-size: 13px;
  font-weight: bold;
  color: #666;
  border-radius: 5px 5px 0 0;
  transition: all 0.2s;
}

.sub-tab:hover {
  background: #e0e0e0;
}

.sub-tab.active {
  background: #4A90D9;
  color: white;
}

.sub-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.sub-tab-content.active {
  display: block;
}

/* 툴바 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar h3, .toolbar h4 {
  font-size: 16px;
  color: #4A90D9;
}

/* 버튼 */
.btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #4A90D9, #357ABD);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(74, 144, 217, 0.4);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-success {
  background: linear-gradient(135deg, #28a745, #218838);
}

.btn-danger {
  background: linear-gradient(135deg, #dc3545, #c82333);
  padding: 5px 10px;
  font-size: 12px;
}

.btn-secondary {
  background: linear-gradient(135deg, #6c757d, #5a6268);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-edit {
  background: linear-gradient(135deg, #ffc107, #e0a800);
  padding: 5px 10px;
  font-size: 12px;
}

/* 테이블 */
.table-container {
  flex: 1;
  overflow: auto;
  border: 1px solid #ddd;
  border-radius: 5px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 800px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: #4A90D9;
  color: white;
  padding: 10px 8px;
  text-align: center;
  font-weight: bold;
  border: 1px solid #3a7bc8;
  white-space: nowrap;
}

td {
  padding: 8px;
  text-align: center;
  border: 1px solid #ddd;
  background: white;
}

tbody tr:hover td {
  background: #f0f7ff;
}

tbody tr:nth-child(even) td {
  background: #fafafa;
}

tbody tr:nth-child(even):hover td {
  background: #f0f7ff;
}

/* 모달 */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 5px 30px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 15px 20px;
  background: linear-gradient(135deg, #4A90D9, #357ABD);
  color: white;
  border-radius: 10px 10px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 15px 20px;
  background: #f5f5f5;
  border-radius: 0 0 10px 10px;
  text-align: right;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* 폼 스타일 */
.form-group {
  margin-bottom: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.form-row .form-group {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 13px;
  background-color: white;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #4A90D9;
  box-shadow: 0 0 5px rgba(74, 144, 217, 0.3);
}

input:read-only {
  background-color: #f0f0f0;
  color: #666;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* 점수 그리드 */
.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.score-grid .form-group {
  margin-bottom: 0;
}

.divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 15px 0;
}

.section-title {
  font-size: 14px;
  color: #4A90D9;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid #4A90D9;
}

/* 알림 메시지 */
.alert {
  padding: 12px 20px;
  border-radius: 5px;
  margin-bottom: 15px;
  display: none;
  flex-shrink: 0;
}

.alert.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert.show {
  display: block;
}

/* 아이템 리스트 (레벨, 타입 관리) */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: #f8f9fa;
  border-radius: 5px;
  border: 1px solid #ddd;
  gap: 10px;
  flex-wrap: wrap;
}

.item-row .item-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-row .order-btn {
  background: #e0e0e0;
  border: none;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 10px;
  border-radius: 3px;
  transition: background 0.2s;
}

.item-row .order-btn:hover {
  background: #4A90D9;
  color: white;
}

.item-row .item-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 150px;
}

.item-row .item-name {
  font-weight: bold;
  color: #333;
}

.item-row .item-desc {
  color: #666;
  font-size: 12px;
}

.item-row .item-actions {
  display: flex;
  gap: 5px;
}

/* 이력 스타일 */
.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  gap: 15px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.history-item:last-child {
  border-bottom: none;
}

.history-date {
  color: #666;
  font-size: 12px;
  min-width: 120px;
}

.history-content {
  flex: 1;
  min-width: 200px;
}

.history-field {
  font-weight: bold;
  color: #4A90D9;
  margin-bottom: 4px;
}

.history-change {
  font-size: 12px;
}

.history-change .old {
  color: #dc3545;
  text-decoration: line-through;
}

.history-change .arrow {
  color: #666;
  margin: 0 8px;
}

.history-change .new {
  color: #28a745;
  font-weight: bold;
}

.no-history {
  text-align: center;
  color: #999;
  padding: 30px;
}

/* 액션 버튼 */
.action-btns {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 단어 선택 */
.word-selector {
  border: 1px solid #ddd;
  border-radius: 5px;
  overflow: hidden;
}

.word-search {
  padding: 10px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.word-search input {
  margin-bottom: 0;
}

.word-list-container {
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
}

.word-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.word-item:hover {
  background: #f0f7ff;
}

.word-item.selected {
  background: #e8f4fd;
}

.word-item input[type="checkbox"] {
  width: auto;
  margin-right: 10px;
}

.selected-words {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 100px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #f8f9fa;
}

.selected-word-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: #4A90D9;
  color: white;
  border-radius: 3px;
  font-size: 12px;
}

.selected-word-tag .remove {
  cursor: pointer;
  font-weight: bold;
}

/* 도움말 텍스트 */
.help-text {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
}

/* 토글 스위치 */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #28a745;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* 반응형 */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header h1 {
    font-size: 20px;
  }

  .tab {
    padding: 10px;
    font-size: 12px;
  }

  .tab-content {
    padding: 15px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal {
    max-width: 100%;
    margin: 10px;
    max-height: calc(100vh - 20px);
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  table {
    font-size: 11px;
    min-width: 600px;
  }

  th, td {
    padding: 6px 4px;
  }

  .btn {
    padding: 8px 15px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .tabs {
    flex-direction: column;
  }

  .tab {
    flex: none;
    width: 100%;
  }

  .score-grid {
    grid-template-columns: 1fr;
  }

  .item-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .item-row .item-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
