/* 1. 변수 및 초기화 */
:root {
  --primary-color: #3d5afe;
  --bg-color: #f4f7f9;
  --header-bg: #ffffff;
  --card-bg: #ffffff;
  --text-main: #2c3e50;
  --text-sub: #7f8c8d;
  --border-color: #e0e6ed;
  --accent-gold: #f1c40f;
}

/* 다크 테마 변수 */
.dark-theme {
  --bg-color: #1a1c1e;
  --header-bg: #25282c;
  --card-bg: #2d3136;
  --text-main: #ececec;
  --text-sub: #b0b0b0;
  --border-color: #3f444a;
}

* { box-sizing: border-box; }
/* 1. body 설정: 최소 너비 1200px 고정 */
body {
  margin: 0;
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: background 0.3s, color 0.3s;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 1200px; /* [요구사항] 최소 넓이 고정 */
}

/* 2. 배경 이미지 (20% 투명도 가상 요소) */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;  
  /* background: url('../images/background.png') no-repeat center center / cover; */
  /* background: url('https://cdn-lostark.game.onstove.com/uploadfiles/banner/636058155051294780.jpg') no-repeat center center / cover;   */
  background: url('https://cdn-lostark.game.onstove.com/developer/assets/images/main_BG.jpg') no-repeat center center / cover;  
  opacity: 0.5;
  z-index: -1;
}

/* 3. 공통 레이아웃 */
.header-container {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding-left: 20px;
  padding-right: 20px; /* 좌우 여백 확보 */
}

/* 4. Header 스타일 (상단 고정) */
.main-header {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding-left: 20px;
  padding-right: 20px; /* 좌우 여백 확보 */

  /* [변경] sticky 대신 Flex 구조 안에서 자연스럽게 상단 배치 */
  /* position: sticky;  <-- 삭제해도 됨 (flex-direction: column이라 자동 상단 배치) */
  
  height: 60px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  
  /* [추가] 공간이 부족해도 찌그러지지 않게 고정 */
  flex-shrink: 0; 
}

/* 5. Main Body 설정 (가변 영역 + 내부 스크롤) */
.main-body {
  /* [추가] 남은 공간을 모두 차지함 */
  flex: 1; 
  
  /* [추가] 내용이 넘치면 이 영역 안에서만 스크롤 생김 */
  overflow-y: auto; 
  
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding-left: 20px;
  padding-right: 20px; /* 좌우 여백 확보 */
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}

.logo { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 1.2rem; }

/* 새소식 슬라이더 */
.notice-slider {
  flex: 1;
  margin: 0 40px;
  background: rgba(0,0,0,0.05);
  padding: 8px 15px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}
.notice-text { 
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}

.header-tools { display: flex; gap: 10px; align-items: center; } /* gap 조정 */

.header-tools select {
  padding: 5px; border-radius: 4px; border: 1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-main);
  height: 32px; /* 높이 통일 */
}

/* [추가/수정] 헤더 툴바 버튼 공통 스타일 */
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color); /* 테두리 추가로 버튼 느낌 강화 */
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none; /* a 태그 밑줄 제거 */
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tool-btn:hover {
  background: var(--border-color); /* 호버 효과 */
  color: var(--primary-color);
}

/* 5. 계정별 탭 (Account Tabs) */
.account-tabs {
  display: flex;
  gap: 5px;
  margin: 20px 0;
  padding: 0 10px;
}

.tab-item {
  padding: 10px 20px;
  background: var(--border-color);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 0.9rem;
  position: relative;
  transition: 0.2s;
  color: var(--text-sub);
}

.tab-item.active {
  background: var(--card-bg);
  color: var(--primary-color);
  font-weight: bold;
  border: 1px solid var(--border-color);
  border-bottom: none;
}

.tab-item .fa-times {
  margin-left: 10px;
  font-size: 0.7rem;
}
.tab-item .fa-times:hover { color: #ff4d4f; }

/* 6. 캐릭터 그리드 (6개 단위) */
.character-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 핵심: 6컬럼 그리드 */
  gap: 15px;
  padding: 10px;
}

/* 반응형: 화면이 좁아지면 컬럼 수 조절 */
@media (max-width: 1100px) { .character-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .character-grid { grid-template-columns: repeat(1, 1fr); } }

.char-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 15px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px rgba(0,0,0,0.03);
  transition: transform 0.2s;
  position: relative; /* 드래그 핸들 위치 잡기 위함 */
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.char-card:hover { transform: translateY(-5px); }

.char-info { margin-bottom: 15px; }
.char-name { display: block; font-weight: bold; font-size: 0.95rem; margin-bottom: 5px; }
.char-level { color: var(--accent-gold); font-weight: bold; font-size: 0.85rem; }
.char-class { font-size: 0.8rem; color: var(--text-sub); margin-left: 5px; }

/* 게이지 바 스타일 */
.raid-status { font-size: 0.8rem; }
progress {
  width: 100%;
  height: 8px;
  appearance: none;
  margin-top: 5px;
}
progress::-webkit-progress-bar { background: var(--border-color); border-radius: 10px; }
progress::-webkit-progress-value { background: var(--primary-color); border-radius: 10px; }

/* 7. Footer 설정 (하단 고정 및 수축 방지) */
.main-footer {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding-left: 20px;
  padding-right: 20px; /* 좌우 여백 확보 */

  /* 기존 스타일 유지 */
  text-align: center;
  padding: 5px 0; /* 높이를 고려해 여백 조정 */
  color: var(--text-sub);
  font-size: 0.85rem;
  
  /* [추가] 하단 고정 및 배경색 지정 (컨텐츠 위로 겹쳐 보이지 않게) */
  flex-shrink: 0;   /* 찌그러짐 방지 */
  background-color: var(--bg-color); /* 배경색을 주어 스크롤되는 내용 가림 */
  border-top: 1px solid var(--border-color); /* 상단 구분선 추가 추천 */
}

/* 모달 오버레이 및 스타일 */
.ui-modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ui-modal {
  background: var(--card-bg);
  width: 400px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: fadeIn 0.2s ease-out;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}
.modal-header .fa-times { cursor: pointer; color: var(--text-sub); }
.modal-header .fa-times:hover { color: var(--text-main); }

.modal-body { padding: 20px; }

.input-group { margin-bottom: 15px; }
.input-label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: var(--text-sub); }
.full-width-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-main);
  outline: none;
}
.full-width-input:focus { border-color: var(--primary-color); }

.modal-footer {
  padding: 15px 20px;
  background: var(--bg-color); /* 약간 다른 톤 */
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-verify, .btn-add {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-verify { background: var(--text-sub); color: white; }
.btn-verify:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-verify.active { background: var(--primary-color); }

.btn-add { background: var(--accent-gold); color: #333; font-weight: bold; }
.btn-add:disabled { background: var(--border-color); color: var(--text-sub); cursor: not-allowed; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 헤더 전용 강조 버튼 (데이터 없을 때 노출) */
.btn-header-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px; /* 아이콘과 텍스트 사이 간격 */
  height: 32px;
  padding: 0 16px;
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-header-primary:hover {
  background-color: #2c42d6; /* 호버 시 약간 어둡게 */
}

/* 다크모드 대응 (필요시) */
.dark-theme .btn-header-primary {
  color: #fff; /* 다크모드에서도 흰색 글씨 유지 */
}

/* 도움말 아이콘 (물음표) 스타일 */
.help-link {
  margin-left: 6px;
  color: var(--text-sub); /* 기본적으로 회색 톤 */
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.2s;
  cursor: pointer;
}

.help-link:hover {
  color: var(--primary-color); /* 마우스 올리면 강조색 */
}

/* 서버별 캐릭터 정보 추가 */
/* deploy/css/style.css 맨 아래 추가 */

/* 서버 섹션 구분 */
.server-section {
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}
.server-title {
  font-size: 1.2rem;
  margin-bottom: 15px;
  padding-left: 10px;
  border-left: 4px solid var(--primary-color);
  color: var(--text-main);
}
.gold-summary {
  font-size: 0.9rem;
  color: var(--accent-gold);
  margin-left: 10px;
  font-weight: normal;
}

/* 6. 캐릭터 그리드 (무조건 6열) */
.character-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* [요구사항] 6개씩 배치 */
  gap: 15px;
  padding: 10px;
}

/* 캐릭터 카드 디자인 */
.char-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 15px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px rgba(0,0,0,0.03);
  transition: transform 0.2s;
  position: relative; /* 드래그 핸들 위치 잡기 위함 */
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

/* 배경 이미지 및 오버레이 */
.char-bg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover;
  background-position: top center;
  z-index: 0;
  transition: transform 0.3s;
}
.char-card:hover .char-bg { transform: scale(1.05); }

.char-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  /* 이미지 위 텍스트 가독성을 위한 그라데이션 */
  background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.8) 50%, rgba(0,0,0,0.95) 100%);
  z-index: 1;
}

/* 카드 내부 콘텐츠 (오버레이 위) */
.char-header, .char-body {
  position: relative;
  z-index: 2;
  color: #fff; /* 배경이 어두우므로 흰색 폰트 */
  padding: 15px;
}

/* 헤더 정보 */
.char-header { border-bottom: 1px solid rgba(255,255,255,0.2); }
.row-top { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 4px; opacity: 0.9; }
.row-name { margin-bottom: 4px; }
.text-level { color: var(--accent-gold); font-weight: bold; margin-right: 5px; }
.text-name { font-size: 1.1rem; }
.row-combat { font-size: 0.8rem; opacity: 0.8; }

/* 본문 영역 */
.char-body { flex: 1; display: flex; flex-direction: column; gap: 15px; font-size: 0.85rem; }

.section-title {
  font-weight: bold;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 5px;
  margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--accent-gold);
}

/* 레이드 리스트 */
.raid-list { display: flex; flex-direction: column; gap: 8px; }
.raid-item {
  background: rgba(255,255,255,0.05);
  padding: 8px;
  border-radius: 6px;
}
.raid-top { display: flex; align-items: center; margin-bottom: 2px; }
.raid-name { font-weight: bold; margin-left: 5px; }
.raid-meta { font-size: 0.75rem; color: #ccc; margin-left: 24px; }
.raid-gold { font-size: 0.8rem; margin-left: 24px; color: #ffeb3b; }
.gold-private { color: #aaa; margin-left: 5px; font-size: 0.75rem; }

/* 할 일 리스트 */
.todo-list { display: flex; flex-direction: column; gap: 6px; }
.todo-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0;
}
.todo-content { margin-left: 5px; word-break: break-all; }
.todo-actions { opacity: 0; transition: opacity 0.2s; }
.todo-item:hover .todo-actions { opacity: 1; }
.todo-actions i { margin-left: 5px; cursor: pointer; color: #ccc; }
.todo-actions i:hover { color: #fff; }

/* 공통 유틸 */
.strike-through { text-decoration: line-through; opacity: 0.5; }
.btn-icon-small { background: none; border: none; color: #fff; cursor: pointer; }
.empty-msg { font-size: 0.8rem; color: #777; text-align: center; padding: 10px; }

/* 커스텀 체크박스 */
.checkbox-wrapper { display: inline-flex; align-items: center; cursor: pointer; }
.checkbox-wrapper input { display: none; }
.checkmark {
  width: 16px; height: 16px;
  border: 1px solid #aaa; border-radius: 3px;
  display: inline-block; position: relative; margin-right: 5px;
}
.checkbox-wrapper input:checked + .checkmark { background-color: var(--primary-color); border-color: var(--primary-color); }
.checkbox-wrapper input:checked + .checkmark::after {
  content: '✔'; position: absolute; font-size: 10px; color: white; top: -2px; left: 2px;
}

/* [추가] 드래그 앤 드롭 스타일 */
.draggable-item {
  cursor: grab;
}
.draggable-item:active {
  cursor: grabbing;
}
.drag-over {
  border: 2px dashed var(--primary-color) !important;
  opacity: 0.7;
}

/* 캐릭터 이동 핸들 (우측 상단) */
.drag-handle-char {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  color: rgba(255, 255, 255, 0.7);
  cursor: grab;
  font-size: 1.2rem;
  padding: 5px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
}
.drag-handle-char:hover {
  color: #fff;
  background: var(--primary-color);
}

/* 서버 이동 핸들 */
.drag-handle-server {
  cursor: grab;
  margin-right: 8px;
  color: var(--text-sub);
}
.drag-handle-server:hover { color: var(--primary-color); }

/* [수정] 캐릭터 이름 1줄 말줄임표 처리 */
.char-name { 
  display: block; 
  font-weight: bold; 
  font-size: 1.1rem; /* 폰트 사이즈 조정 */
  margin-bottom: 5px;
  
  /* 1줄 말줄임 핵심 CSS */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* [추가] 로딩 마스크 (Masking) */
.loading-mask {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 1.2rem;
}
.loading-spinner {
  border: 5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top: 5px solid var(--primary-color);
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 골드 텍스트 작게 */
.gold-sub-text {
  font-size: 0.8rem;
  color: var(--accent-gold);
  margin-left: auto; /* 우측 정렬 */
}