/* 기본 스타일 및 리셋 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #f8f9fa;
  color: #333;
  line-height: 1.6;
}

.container {
  width: 100%;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 상단 네비게이션 바 */
.navbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
  height: 32px;
  padding: 0;
}

/* 드롭다운 메뉴 스타일 */
.nav-item {
  position: relative;
}

.nav-link {
  padding: 8px 20px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  transition: color 0.3s;
  display: block;
}

.nav-link:hover {
  color: #007bff;
}

.nav-item:hover .dropdown-menu {
  display: block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.dropdown-item {
  display: block;
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
}

/* S&P TOP 10 탭 스타일 */
.tab {
  padding: 8px 20px;
  background-color: #e0e0e0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

.tab:hover {
  background-color: #ccc;
}

/* 모바일 메뉴 토글 버튼 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 10px;
}

/* 모바일 메뉴 */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: white;
  z-index: 2000;
  overflow-y: auto;
}

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.close-menu {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.mobile-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-dropdown {
  border-bottom: 1px solid #eee;
}

.mobile-dropdown-toggle {
  width: 100%;
  padding: 15px 20px;
  background: none;
  border: none;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  color: #333;
  text-decoration: none;
  display: block;
}

.mobile-submenu {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-submenu li a {
  display: block;
  padding: 12px 40px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #f5f5f5;
}

.mobile-submenu li:last-child a {
  border-bottom: none;
}

.mobile-menu ul li a {
  display: block;
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #eee;
}

.mobile-menu ul li:last-child a {
  border-bottom: none;
}

/* 모바일 메뉴 활성화 스타일 */
.mobile-menu.active {
  display: block;
}

/* 모바일 드롭다운 활성화 스타일 */
.mobile-dropdown.active .mobile-submenu {
  display: block;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .nav-item, .tab {
    display: none;
  }
  
  .menu-toggle {
    display: block;
  }
}

/* 헤더 스타일 */
.header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 10px 0;
  margin-bottom: 1px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto;
  padding: 0;
}

.logo {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  text-decoration: none;
}

/* 네비게이션 바 */
.navbar {
  display: flex;
  gap: 20px;
  align-items: center;
  height: 16px;
  padding: 0;
}

.nav-item {
  position: relative;
}

.nav-link {
  padding: 8px 12px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  transition: color 0.3s;
  display: block;
}

.nav-link:hover {
  color: #007bff;
}

.nav-item:hover .dropdown-menu {
  display: block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
  border-radius: 4px;
}

.dropdown-item {
  display: block;
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
}

/* S&P TOP 10 탭 스타일 */
.tab {
  padding: 8px 12px;
  background-color: #007bff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
  color: white;
}

.tab:hover {
  background-color: #0056b3;
}

/* 모바일 메뉴 토글 버튼 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 10px;
  color: #333;
}

/* 모바일 메뉴 */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: white;
  z-index: 2000;
  overflow-y: auto;
}

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.close-menu {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #333;
}

.mobile-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-dropdown {
  border-bottom: 1px solid #eee;
}

.mobile-dropdown-toggle {
  width: 100%;
  padding: 15px 20px;
  background: none;
  border: none;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  color: #333;
  text-decoration: none;
  display: block;
}

.mobile-submenu {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-submenu li a {
  display: block;
  padding: 12px 40px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #f5f5f5;
}

.mobile-submenu li:last-child a {
  border-bottom: none;
}

.mobile-menu ul li a {
  display: block;
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #eee;
}

.mobile-menu ul li:last-child a {
  border-bottom: none;
}

/* 모바일 메뉴 활성화 스타일 */
.mobile-menu.active {
  display: block;
}

/* 모바일 드롭다운 활성화 스타일 */
.mobile-dropdown.active .mobile-submenu {
  display: block;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .nav-item, .tab {
    display: none;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .header-content {
    padding: 0;
  }
}

/* 북마크 바 스타일 */
.bookmark-bars {
  margin-bottom: 1px;
}

.bookmark-bar {
  display: flex;
  align-items: center;
  margin-bottom: 1px;
  flex-wrap: wrap;
}

.bookmark-title {
  font-weight: bold;
  margin-right: 10px;
  white-space: nowrap;
}

.bookmark-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.bookmark-item {
  padding: 5px 10px;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.bookmark-item:hover {
  background-color: #dee2e6;
}

.add-bookmark-btn {
  margin-left: 10px;
  padding: 5px 10px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-bookmark-btn:hover {
  background-color: #0056b3;
}

/* 모바일 반응형 북마크 바 */
@media (max-width: 768px) {
  .bookmark-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .bookmark-title {
    margin-bottom: 5px;
  }
  
  .bookmark-items {
    width: 100%;
    margin-bottom: 10px;
  }
  
  .add-bookmark-btn {
    margin-left: 0;
    margin-top: 5px;
  }
}

/* 검색/정렬 바 */
.search-sort-bar {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

#search-input {
  min-width: 200px;
  width: 400px;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  height: 36px;
  box-sizing: border-box;
}

/* RSI 정렬 아이콘 버튼 스타일 */
.rsi-sort-btn {
  padding: 6px 10px;
  background-color: #007bff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: white;
  align-self: center;
}

.rsi-sort-btn:hover {
  background-color: #0056b3;
}

/* 날짜 입력 필드 스타일 */
#date-input {
  padding: 8px 12px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  min-width: 140px;
  height: 36px;
  box-sizing: border-box;
  font-weight: bold;
  color: #007bff;
}

/* 날짜 이동 버튼 스타일 */
.date-navigation {
  display: flex;
  align-items: center;
  gap: 2px;
  background-color: #f8f9fa;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

.date-nav-btn {
  padding: 6px 10px;
  background-color: #007bff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: white;
}

.date-nav-btn:hover {
  background-color: #0056b3;
}

/* 메인 컨텐츠 영역 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 종목 리스트 영역 */
.stock-list-container {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.stock-list {
  list-style: none;
  padding: 0;
}

.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #eee;
  background-color: white;
  transition: background-color 0.2s;
}

.stock-item:hover {
  background-color: #f9f9f9;
}

.stock-info {
  flex: 1;
}

.stock-ticker,
.stock-name,
.stock-code {
  font-weight: bold;
  margin-right: 10px;
}

.stock-prices {
  margin-top: 8px;
  font-size: 14px;
  color: #666;
}

.price-label {
  font-weight: bold;
  margin-right: 5px;
}

.price-value {
  margin-right: 15px;
}

.stock-rsi {
  font-weight: bold;
  padding: 5px 10px;
  border-radius: 4px;
  color: white;
}

.rsi-overbought {
  background-color: #ff4d4d; /* 빨강 */
}

.rsi-oversold {
  background-color: #4da6ff; /* 파랑 */
}

.rsi-neutral {
  background-color: #888; /* 회색 */
}

/* 반응형 */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
  }

  .search-sort-bar {
    flex-direction: column;
  }

  #search-input {
    width: 100%;
  }

  .stock-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .stock-info {
    width: 100%;
  }

  .stock-rsi {
    align-self: flex-end;
  }
}

/* 디버그 정보 스타일 */
.debug-header {
  padding: 15px;
  background-color: #007bff;
  color: white;
  font-weight: bold;
  border-radius: 6px;
  margin-bottom: 10px;
}

.debug-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #eee;
  background-color: white;
  transition: background-color 0.2s;
}

.debug-item:hover {
  background-color: #f9f9f9;
}

.debug-key {
  font-weight: bold;
  margin-right: 10px;
}

.debug-value {
  font-family: monospace;
  word-break: break-all;
  text-align: right;
}

/* 로딩, 에러, 데이터 없음 메시지 스타일 */
.loading,
.error,
.no-data {
  text-align: center;
  padding: 20px;
  font-style: italic;
}

.loading {
  color: #007bff;
}

.error {
  color: #ff4d4d;
}

.no-data {
  color: #888;
}
/* 테이블 반응형 및 최소 폭 */
#stock-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  margin-bottom: 20px;
  table-layout: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 8px;
  overflow: hidden;
}
#stock-table th, #stock-table td {
  border: none;
  border-bottom: 1px solid #e0e0e0;
  border-right: 1px solid #e0e0e0;
  padding: 12px 8px;
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
}
#stock-table th:last-child,
#stock-table td:last-child {
  border-right: none;
}
#stock-table tr:last-child td {
  border-bottom: none;
}
#stock-table th {
  background: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  padding: 16px 8px;
}
#stock-table th:hover {
  background: #e9ecef;
}
#stock-table th.sorted-asc::after {
  content: " ↑";
  opacity: 0.8;
}
#stock-table th.sorted-desc::after {
  content: " ↓";
  opacity: 0.8;
}
#stock-table th.no-sort::after {
  content: " ↕";
  opacity: 0.3;
}
#stock-table tbody tr:nth-child(even) {
  background-color: #f8f9fa;
}
#stock-table tbody tr:hover {
  background-color: #e9f7fe;
}
.stock-table-wrapper {
  width: 100%;
  overflow-x: auto;
  min-width: 0;
  border-radius: 8px;
}
/* RSI 값 색상 */
.rsi-overbought {
  background-color: #ff6b6b;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.rsi-oversold {
  background-color: #4d96ff;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.rsi-neutral {
  background-color: #6c757d;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}
/* 반응형 테이블 개선 */
@media (max-width: 768px) {
  #stock-table {
    min-width: 100%;
    font-size: 12px;
  }
  #stock-table th, #stock-table td {
    padding: 8px 4px;
    font-size: 12px;
  }
  #stock-table th {
    padding: 10px 4px;
  }
}

/* 종목명 링크 스타일 */
.stock-name-link {
  color: #007bff;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s;
}

.stock-name-link:hover {
  color: #0056b3;
}

/* 팝업 메뉴 스타일 */
.popup-menu {
  position: absolute;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 1000;
  min-width: 120px;
}

.popup-menu-item {
  padding: 10px 15px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.popup-menu-item:hover {
  background-color: #f5f5f5;
}

/* 리셋 버튼 스타일 */
.reset-btn {
  padding: 6px 10px;
  background-color: #007bff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: white;
  align-self: center;
  margin-left: 5px;
}

.reset-btn:hover {
  background-color: #0056b3;
}

/* 가격 및 RSI 변화량 표시를 위한 클래스 */
.price-up {
  color: #ff0000; /* 빨강 */
  font-weight: bold;
}

.price-down {
  color: #0000ff; /* 파랑 */
  font-weight: bold;
}

.rsi-up {
  color: #ff0000; /* 빨강 */
  font-weight: bold;
}

.rsi-down {
  color: #0000ff; /* 파랑 */
  font-weight: bold;
}

/* 실시간 지수 정보 표시 영역 */
.indices-info {
  margin-bottom: 5px;
  padding: 0 10px;
  background-color: #e9f7fe;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  height: 20px;
  display: flex;
  align-items: center;
  overflow: hidden;
  overflow-x: hidden;
}

.indices-line {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 15px;
  width: 100%;
  align-items: center;
}

.index-item {
  font-weight: bold;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
}

/* 반응형 지수 정보 표시 */
@media (max-width: 768px) {
  .indices-line {
    display: inline-block;
    animation: marquee 20s linear infinite;
    white-space: nowrap;
    padding-right: 20px;
  }
  
  .index-item {
    font-size: 14px;
    display: inline-block;
    margin-right: 15px;
  }
  
  /* 스트리밍 애니메이션 */
  @keyframes marquee {
    0% {
      transform: translateX(100%);
    }
    100% {
      transform: translateX(-100%);
    }
  }
}
