/* Simplified CSS to fix display issues and match original structure */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box; /* Added box-sizing to prevent overflow */
}

/* 사이트 카테고리 뱃지 스타일 */
.site-category {
  display: inline-block;
  padding: 1px 4px;
  margin-right: 4px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  color: white !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
  vertical-align: middle;
  line-height: 1;
  text-decoration: none !important;
}

/* 전체 메뉴에서 뱃지와 제목을 하나의 flex 아이템으로 묶기 */
.title-container {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

/* 각 사이트별 고유 색상 */
.site-ppom { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.site-globalppom { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.site-ruli { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); color: #333 !important; }
.site-qzone { background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%); }
.site-clien { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.site-cnj { background: linear-gradient(135deg, #fdbb2d 0%, #22c1c3 100%); }
.site-fmk { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.site-iv { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.site-etc { background: linear-gradient(135deg, #c3c3c3 0%, #8a8a8a 100%); }

html,
body {
  height: 100%;
  background-color: #eff2f8;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "맑은 고딕", sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.267;
  color: #000;
  overflow-x: hidden; /* Prevent horizontal scroll on body */
  margin: 0;
  padding: 0;
}

#main {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

#frame_top {
  width: 100%;
  height: 35px;
  overflow: hidden;
  position: fixed; /* Fixed positioning to prevent menu movement */
  top: 0;
  left: 0;
  z-index: 1000;
}

#frame_top iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

#frame_bottom {
  width: 100%;
  height: calc(100vh - 35px);
  height: -webkit-calc(100vh - 35px);
  overflow: hidden;
  position: absolute;
  top: 35px;
  left: 0;
  padding: 0;
  margin: 0;
}

#frame_bottom iframe {
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  /* Safari specific fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Header styles */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 35px;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-title {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  border-right: 1px solid rgba(255,255,255,0.2);
  margin-right: 4px;
  text-decoration: none;
  display: flex;
  align-items: center;
  height: 100%;
  transition: background-color 0.2s ease;
}

.header-title:hover {
  background-color: rgba(255,255,255,0.15);
}

.sub_menu {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  flex: 1;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sub_menu::-webkit-scrollbar {
  display: none; /* Safari/Chrome */
}

.header li {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  height: 100%;
  min-width: -webkit-fit-content;
  min-width: -moz-fit-content;
  min-width: fit-content;
  float: left; /* Safari fallback */
}

.header a {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  height: 100%;
  color: #fff !important;
  text-decoration: none;
  font-weight: bold;
  white-space: nowrap; /* Prevent text wrapping */
}

.header a span {
  display: block;
  padding: 8px 6px; /* Reduced horizontal padding from 12px to 6px for tighter spacing */
  color: #fff !important;
  font-weight: bold;
}

.header a:hover {
  background-color: rgba(255,255,255,0.15);
}

/* Selected menu item styling */
.header li.on a,
.header li.x.on a {
  background-color: rgba(255,255,255,0.25);
  color: #fff !important;
  border-bottom: 2px solid #fff;
}

.header li.on a span,
.header li.x.on a span {
  color: #fff !important;
}

/* List styles */
.type1 {
  width: 100%;
  padding: 0;
  margin: 0;
  overflow-x: hidden; /* Prevent horizontal scroll in lists */
  box-sizing: border-box;
}

.type1 ul {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.type1 li {
  border-bottom: 1px solid #ddd;
  margin: 0;
  padding: 0;
}

.type1 li:first-child {
  margin-top: 0;
  padding-top: 0;
}

.type1 li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 6px 8px 6px;
  text-decoration: none;
  color: #000;
  line-height: 18px;
}

.type1 li span {
  font-size: 11px;
  color: #919191;
  white-space: nowrap;
  flex-shrink: 0;
}

.type1 h4 {
  font-size: 15px;
  font-weight: bold;
  border-bottom: 2px solid #c3c3c3;
  padding: 0 0 5px 5px;
  margin-top: 10px;
}

.type1 .tit_sub {
  padding: 5px;
}


/* Mobile responsive */
@media (max-width: 480px) {
  #frame_top {
    height: 40px;
  }
  #frame_bottom {
    /* Height will be set by JavaScript for mobile */
    top: 40px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
  }
  #frame_bottom iframe {
    height: 100%;
    min-height: 100%;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
  }
  .header a span {
    padding: 6px 6px;
    font-size: 13px;
  }
  .header-title {
    font-size: 11px;
    padding: 0 8px;
    margin-right: 2px;
  }
  .header-title:hover {
    background-color: rgba(255,255,255,0.15);
  }
  .type1 {
    padding-bottom: 5px; /* Minimal padding for cleaner look */
    padding-top: 0;
    margin-top: 0;
    min-height: auto;
  }
  .pagenation {
    padding: 8px 0; /* Minimal padding for cleaner spacing */
    margin: 5px 0;
  }
  .type1 ul {
    margin-top: 0;
    padding-top: 0;
  }
  .type1 li:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  body {
    margin: 0;
    padding: 0;
  }
}

/* Pagination styles */
.pagenation {
  text-align: center;
  padding: 8px 0;
  margin: 5px 0;
}

.pagenation a {
  display: inline-block;
  padding: 5px 8px;
  margin: 0 2px;
  text-decoration: none;
  color: #666;
  border: 1px solid #ddd;
  background-color: #fff;
  font-size: 12px;
  line-height: 1;
}

.pagenation a:hover {
  background-color: #f5f5f5;
  color: #333;
}

.pagenation a.on {
  background-color: #666;
  color: #fff;
  border-color: #666;
}

/* Navigation arrows */
.pagenation a[title*="이전"],
.pagenation a[title*="다음"] {
  font-weight: bold;
}

/* Safari specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .header li {
    display: inline-block;
    vertical-align: top;
    float: left;
  }

  .sub_menu {
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #frame_bottom {
    -webkit-overflow-scrolling: touch;
  }
}

/* iOS Safari specific */
@supports (-webkit-touch-callout: none) {
  .header {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .sub_menu {
    -webkit-overflow-scrolling: touch;
  }

  #frame_bottom iframe {
    -webkit-overflow-scrolling: touch;
    overflow: auto;
  }

  body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    overflow-y: auto;
  }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
  .sub_menu {
    scrollbar-width: none;
  }

  .header li {
    display: inline-block;
    vertical-align: top;
  }
}

/* Legacy browser support - minimal */
.no-flexbox .sub_menu {
  display: block;
  white-space: nowrap;
}

.no-flexbox .header li {
  display: inline-block;
  vertical-align: top;
}

/* Modern browser optimizations */
@supports (display: flex) {
  .sub_menu {
    display: flex;
    flex-direction: row;
  }

  .header li {
    flex-shrink: 0;
  }
}

/* Theme option styles for setting page */
.theme-option {
  display: block;
  margin: 8px 0;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
  font-weight: 500;
}

.theme-option:hover {
  border-color: #667eea;
  background: #f8f9ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.theme-option input[type="radio"] {
  margin-right: 10px;
  accent-color: #667eea;
}

.theme-option input[type="radio"]:checked + span,
.theme-option:has(input[type="radio"]:checked) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Dark theme styles */
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"],
[data-theme="dark"] html,
[data-theme="dark"] body {
  background-color: #1a1a1a !important;
  color: #e0e0e0 !important;
}

/* Force dark mode on root elements */
html[data-theme="dark"] {
  background-color: #1a1a1a !important;
  color: #e0e0e0 !important;
}

body[data-theme="dark"] {
  background-color: #1a1a1a !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .header {
  background: linear-gradient(135deg, #1a1f3a 0%, #2d1b3d 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .header-title {
  color: #fff;
  border-right: 1px solid rgba(255,255,255,0.15);
}

[data-theme="dark"] .header a:hover {
  background-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .header li.on a,
[data-theme="dark"] .header li.x.on a {
  background-color: rgba(255,255,255,0.15);
  border-bottom: 2px solid #8b7fc7;
}

[data-theme="dark"] .type1 {
  background-color: #1a1a1a;
}

[data-theme="dark"] .type1 li {
  border-bottom: 1px solid #30363d;
}

[data-theme="dark"] .type1 li a {
  color: #e0e0e0;
}

[data-theme="dark"] .type1 li a:hover {
  background-color: #21262d;
}

[data-theme="dark"] .type1 li span {
  color: #8b949e;
}

[data-theme="dark"] .type1 h4 {
  color: #f0f6fc;
  border-bottom-color: #30363d;
}

[data-theme="dark"] .pagenation a {
  background-color: #21262d;
  color: #e0e0e0;
  border-color: #30363d;
}

[data-theme="dark"] .pagenation a:hover {
  background-color: #30363d;
  color: #f0f6fc;
}

[data-theme="dark"] .pagenation a.on {
  background-color: #0969da;
  color: #fff;
  border-color: #0969da;
}

[data-theme="dark"] .theme-option {
  background: #21262d;
  border-color: #3d3d5c;
  color: #e0e0e0;
}

[data-theme="dark"] .theme-option:hover {
  border-color: #8b7fc7;
  background: #2a2d3a;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(139, 127, 199, 0.25);
}

[data-theme="dark"] .theme-option input[type="radio"] {
  accent-color: #8b7fc7;
}

[data-theme="dark"] .theme-option:has(input[type="radio"]:checked) {
  background: linear-gradient(135deg, #1a1f3a 0%, #2d1b3d 100%);
  color: #fff;
  border-color: #8b7fc7;
  box-shadow: 0 4px 12px rgba(139, 127, 199, 0.3);
}

/* Site category badges dark theme */
[data-theme="dark"] .site-category {
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* Floating banner widget */
.floating-banner {
  position: fixed;
  bottom: 20px;
  right: 30px;
  z-index: 9999;
  width: 120px;
  height: 60px;
  opacity: 0.9;
}

.floating-banner:hover {
  opacity: 1;
}

.floating-banner .banner-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
}

.floating-banner .banner-item.active {
  opacity: 1;
  pointer-events: auto;
}

.floating-banner .banner-item:hover {
  transform: scale(1.05);
}

.floating-banner img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Mobile responsive for floating banner */
@media (max-width: 480px) {
  .floating-banner {
    bottom: 10px;
    right: 15px;
    width: 100px;
    height: 50px;
  }
}

/* Dark theme for floating banner */
[data-theme="dark"] .floating-banner img {
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Ensure smooth theme transitions */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.type1,
.type1 li,
.type1 li a,
.header,
.header a,
.pagenation a,
.theme-option {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
