/* /var/www/maple-app/css/style.css - 전역 레이아웃 및 3단 네비게이션, 타이머 대시보드 스타일 */
:root {
  --bg-main: #14161d;
  --bg-card: #1e222d;
  --bg-header: #101217;
  --border-color: #2e3444;
  --text-main: #e6edf3;
  --text-muted: #8b949e;
  --primary: #f0883e;
  --primary-hover: #ff9854;
  --accent: #58a6ff;
  --danger: #f85149;
  --success: #238636;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

/* ==========================================================================
   1. 상단 네비게이션 헤더 (보스 계산기 / 종합표 / 재획 타이머 3단 메뉴)
   ========================================================================== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 24px; }
.nav-left h2 { font-size: 1.25rem; white-space: nowrap; color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}
.nav-link:hover { color: var(--text-main); background-color: #1a1e27; }
.nav-link.active {
  color: #fff;
  background-color: #21262d;
  border: 1px solid #30363d;
}

/* 메인 컨테이너 */
.container { max-width: 1240px; margin: 24px auto; padding: 0 16px; }

/* ==========================================================================
   2. 재획 타이머 전용 페이지 (/timer) 카드 그리드 스타일
   ========================================================================== */
.timer-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--bg-card);
  padding: 18px 24px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}
.timer-page-header h2 { font-size: 1.4rem; font-weight: 700; }

.timer-page-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* 대형 타이머 카드 */
.timer-hero-card {
  background: #171b24;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px 20px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.timer-hero-card:hover {
  border-color: #48546a;
  background: #1c212c;
  transform: translateY(-2px);
}

/* 동작 중 하이라이트 */
.timer-hero-card.running {
  border-color: var(--primary);
  background: #1f232d;
  box-shadow: 0 0 14px rgba(240, 136, 62, 0.25);
}
.timer-hero-card.running .hero-time {
  color: #ffc107;
}

/* 종료 시 깜빡임 경고 */
.timer-hero-card.ended {
  border-color: var(--danger);
  animation: pulse-alert 0.8s infinite alternate;
}
@keyframes pulse-alert {
  from { box-shadow: 0 0 6px var(--danger); }
  to { box-shadow: 0 0 20px var(--danger); }
}

.hero-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
}
.hero-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}
.badge-rune { background: rgba(240, 136, 62, 0.2); color: var(--primary); }
.badge-union { background: rgba(88, 166, 255, 0.2); color: var(--accent); }
.badge-half { background: rgba(46, 160, 67, 0.2); color: #3fb950; }
.badge-two { background: rgba(163, 113, 247, 0.2); color: #bc8cff; }

.hero-reset-btn {
  background: #252b37;
  border: 1px solid #374052;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.hero-reset-btn:hover { color: #fff; background: #323b4c; }

.hero-time {
  font-size: 2.8rem;
  font-weight: 900;
  font-family: Consolas, monospace;
  margin: 12px 0 4px 0;
  color: #e6edf3;
  letter-spacing: 1px;
}
.hero-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.timer-hero-card.running .hero-status {
  color: #3fb950;
  font-weight: 600;
}

.hero-progress {
  width: 100%;
  height: 6px;
  background: #252b38;
  border-radius: 3px;
  overflow: hidden;
}
.hero-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 1s linear;
}
.hero-progress-bar.bar-union { background: var(--accent); }

/* 유니온 제어 액션 카드 */
.timer-action-card {
  background: var(--bg-card);
  border: 1px dashed #3e4759;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.timer-action-card h3 { font-size: 1.15rem; margin-bottom: 6px; color: var(--accent); }
.timer-action-card p { font-size: 0.85rem; margin-bottom: 16px; }

/* ==========================================================================
   3. 보스 계산기 (메인) & 종합표 (/record) 공통 스타일
   ========================================================================== */
.summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #1f2737, #191e2b);
  border: 1px solid var(--border-color);
  padding: 18px 24px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.grand-profit { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.summary-actions { display: flex; gap: 8px; align-items: center; }

.add-char-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}
.input-group { display: flex; gap: 10px; width: 45%; }
.input-group input, .modal-input-group input, .record-form-grid input, select {
  background: #0d1117;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  width: 100%;
}
.api-status-tag {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #161b22;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #30363d;
}

/* 캐릭터 보스 카드 */
.cards-grid { display: flex; flex-direction: column; gap: 16px; }
.character-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}
.char-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: #171b24;
  border-bottom: 1px solid var(--border-color);
}
.char-profit { font-weight: 700; color: var(--accent); margin-right: 12px; }
.char-ocid { font-size: 0.75rem; color: var(--text-muted); }

.boss-table { width: 100%; border-collapse: collapse; text-align: left; }
.boss-table th, .boss-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #232834;
  vertical-align: middle;
  white-space: nowrap;
}
.boss-table tr.cleared { background-color: rgba(35, 134, 54, 0.12); }
.th-clear, .td-clear { text-align: center; width: 95px; min-width: 95px; }
.party-select { width: 75px; text-align: center; }
.price-cell { font-weight: 600; color: #e6edf3; }

/* 종합표 통계 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
}
.mb-4 { margin-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: 8px;
}
.stat-label { font-size: 0.85rem; color: var(--text-muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; margin-top: 6px; }
.stat-value.highlight { color: var(--accent); }
.total-card { border-color: var(--primary); background: linear-gradient(135deg, #232836, #1e222d); }

/* 기능 설명: 종합표 통계 카드의 수익 텍스트와 게임 아이콘을 정렬하고 도트 이미지를 선명하게 보정하는 스타일 */
.stat-value-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.stat-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  /* 메이플 고유 도트 이미지가 깨지거나 뭉개지지 않도록 픽셀 선명도 유지 */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.stat-card .stat-value {
  margin-top: 0; /* 컨테이너 정렬에 맞춰 기존 상단 여백 제거 */
}

.boss-history-list { list-style: none; margin-top: 12px; }
.boss-week-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #232834;
}
.badge-profit { color: var(--primary); font-weight: 700; font-size: 1.05rem; }

.record-form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 120px;
  gap: 12px;
  margin-top: 16px;
  align-items: flex-end;
}
.record-form-grid label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.form-btn-wrapper button { height: 38px; }
.w-100 { width: 100%; }

/* 버튼 */
button { cursor: pointer; border: none; border-radius: 6px; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; padding: 9px 16px; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #30363d; color: var(--text-main); padding: 9px 15px; }
.btn-outline { background: transparent; border: 1px solid #58a6ff; color: #58a6ff; padding: 9px 15px; }
.btn-outline:hover { background: rgba(88, 166, 255, 0.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { font-size: 0.8rem; padding: 5px 10px; }

/* 모달 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #1b1f28;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 480px;
}
.modal-desc { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 16px 0; }
.modal-status-text { font-size: 0.8rem; margin: 8px 0 18px 0; color: var(--accent); }
.modal-actions { display: flex; justify-content: space-between; align-items: center; }
.modal-right-btns { display: flex; gap: 8px; }

@media (max-width: 900px) {
  .timer-page-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .record-form-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   5. [모바일 전용 UI]: m.도메인 및 768px 이하 스마트폰 최적화
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. 상단 네비게이션: 2열 구성 및 가로 스크롤 탭 */
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
    gap: 8px;
  }
  .nav-left {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .nav-links {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .nav-link {
    font-size: 0.82rem;
    padding: 6px 10px;
    flex-shrink: 0;
  }

  /* 2. 본문 컨테이너 여백 축소 */
  .container {
    padding: 0 10px;
    margin: 14px auto;
  }

  /* 3. 요약 바 세로 배치 */
  .summary-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }
  .grand-profit {
    font-size: 1.5rem;
  }
  .summary-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .summary-actions #btn-refresh-boss {
    grid-column: span 2; /* 갱신 버튼은 하단 전체 너비 */
  }

  /* 4. 캐릭터 등록 폼 세로 정렬 */
  .add-char-section {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .input-group {
    width: 100%;
  }
  .api-status-tag {
    text-align: center;
  }

  /* 5. 보스 테이블 가로 터치 스크롤 지원 */
  .char-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .boss-table th, .boss-table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
  .boss-table select {
    padding: 4px 6px;
    font-size: 0.78rem;
  }
  .party-select {
    width: 58px;
  }

  /* 6. 종합표(/record) 대시보드 및 입력 폼 */
  .stats-grid {
    grid-template-columns: 1fr; /* 1열로 보기 쉽게 정렬 */
    gap: 10px;
  }
  .stat-card {
    padding: 14px;
  }
  .stat-value {
    font-size: 1.2rem;
  }
  .record-form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .form-btn-wrapper button {
    width: 100%;
    margin-top: 4px;
  }

  /* 7. 재획 타이머(/timer) 전용 모바일 레이아웃 */
  .timer-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }
  .timer-page-grid {
    grid-template-columns: 1fr; /* 스마트폰에서는 1열 대형 카드 */
    gap: 14px;
  }
  .timer-hero-card {
    min-height: 150px;
    padding: 18px 14px;
  }
  .hero-time {
    font-size: 2.3rem; /* 모바일 폭에 맞춘 폰트 축소 */
  }
}