/* static/css/modal.css */

/* ── 유틸리티 ── */
/* 모든 .hidden 요소를 확실히 숨깁니다 */
.stock-modal .hidden {
  display: none !important;
}

/* ── 오버레이 ── */
.stock-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000; /* ★ 여기 값만 테마 모달보다 높게 */
}
.stock-modal.hidden {
  display: none;
}
.stock-modal .modal-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.4);
}

.stock-modal .modal-overlay { z-index: 0; }
.stock-modal .modal-card    { z-index: 1; }

/* ── 카드 스타일 ── */
.stock-modal .modal-card {
  position: relative;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 1000px;
  height: 80vh; /* 고정 높이 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 헤더 (#333d4b) ── */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #333d4b;
  color: #fff;
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
}
.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s;
}
.modal-close:hover {
  transform: scale(1.2);
}

/* ── 오늘 통계 ── */
.modal-stats {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}
.modal-stats .stat-item {
  flex: 1;
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.modal-stats .stat-label {
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 4px;
}
.modal-stats .stat-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333d4b;
}
.modal-stats .stat-value.positive {
  color: #e71909;
}
.modal-stats .stat-value.negative {
  color: #115bcb;
}

/* ── 탭 네비 ── */
.stock-modal .modal-tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  margin: 0 24px;
}
.stock-modal .modal-tabs .tab-btn {
  flex: 1;
  padding: 12px 0;
  background: none;
  border: none;
  font-size: 1rem;
  color: #555;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  border-bottom: 3px solid transparent;
}
.stock-modal .modal-tabs .tab-btn.active {
  color: #333d4b;
  border-bottom-color: rgba(51, 61, 75, 0.7);
  font-weight: 600;
}

/* ── 탭 패널 공통 ── */
.stock-modal .tab-panel {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
}
.stock-modal .tab-panel.hidden {
  display: none;
}

.stock-modal .history-card {
  position: relative;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  padding: 12px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
}
.stock-modal .history-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.stock-modal .history-card .hc-date {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 4px;
}
.stock-modal .history-card .hc-theme {
  font-size: 1rem;
  font-weight: 600;
  color: #333d4b;
  margin-bottom: 6px;
}
.stock-modal .history-card .hc-change {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  background: rgba(255,255,255,0.8);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.stock-modal .history-card .hc-change.positive {
  color: #e71909;
}
.stock-modal .history-card .hc-change.negative {
  color: #115bcb;
}
.stock-modal .history-card .hc-comment {
  font-size: 0.85rem;
  color: #555;
  margin-top: 8px;
}

/* ── 종목 메모 ── */
.stock-modal .memo-text {
  font-family: Pretendard Variable, Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7f7f7;
  padding: 12px;
  border-radius: 6px;
  color: #444;
  margin: 0;
}

/* ── 이미지 (데이터 없을 때) ── */
.stock-modal .image-full {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  height: 100%;
}
.stock-modal .image-full.hidden {
  display: none;
}
.stock-modal .image-full img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

/* ── 차트 컨테이너 ── */
.stock-modal #modal-chart-container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-style: italic;
  background: #f0f4f8;
  border-radius: 6px;
  border: 1px dashed #ddd;
}

/* 3) 다른 모달 오버레이들은 이보다 위에서 작동하게 (예: 전체 화면 모달) */
.modal-overlay {
  /* 기존 값에 더 높은 z-index 지정 */
  z-index: 0;
}

/* ── Stock Modal 카드 테두리 ── */
.stock-modal .history-card {
  border: 1px solid #ddd;
}

.stock-modal .history-card:hover {
  border-color: #ccc;
}

/* === 기존 modal.css 하단에 추가 === */

/* 통계: 두 개 컨테이너 유지, 모바일 여백/폰트 최적화 */
.modal-stats {
  display: flex;
  gap: 12px;            /* 16 → 12 */
  padding: 12px 16px;   /* 16 24 → 12 16 */
}
.modal-stats .stat-item {
  min-width: 0;         /* 모바일에서 내용 잘림 방지 */
  align-items: center;
}

/* 왼쪽 카드: 현재가/등락률 세로 배치 */
.modal-stats .stat-item.duo {
  padding: 10px;        /* 살짝 컴팩트 */
}
.modal-stats .stat-item.duo .line-1 {
  /* 현재가(위) — 더 크게 */
  font-size: 1.25rem;   /* 1.2 → 1.25 */
  font-weight: 700;
  line-height: 1.1;
}
.modal-stats .stat-item.duo .line-2 {
  /* 등락률(아래) */
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.1;
}

/* 등락률 색상(아래 줄에 적용) */
.modal-stats #modal-current-change.positive { color: #e71909; }
.modal-stats #modal-current-change.negative { color: #115bcb; }

/* 현재가 색상은 유지(회색) — 필요시 등락 연동하려면 아래 주석 해제
.modal-stats #modal-current-price.positive { color:#e71909; }
.modal-stats #modal-current-price.negative { color:#115bcb; }
*/

/* 모바일 폰트/여백 더 줄이기 */
@media (max-width: 480px) {
  .modal-header { padding: 12px 16px; }
  .modal-header h2 { font-size: 1rem; }

  .modal-stats { gap: 10px; padding: 10px 12px; }
  .modal-stats .stat-item { padding: 10px; }
  .modal-stats .stat-item.duo .line-1 { font-size: 1rem; }
  .modal-stats .stat-item.duo .line-2 { font-size: 0.8rem; }
  .modal-stats .stat-value { font-size: 0.8rem; }
  #modal-today-volume { font-size: 1rem; }
  .stock-modal .modal-tabs { margin: 0 16px; }
  .stock-modal .tab-panel { padding: 12px 16px; }
}

/* === 최신 뉴스 한줄 스트립 === */
.stock-modal #modal-latest-news {
  padding: 8px 24px;
  border-bottom: 1px solid #ddd;
  background: #fafafa;
  font-size: 0.9rem;
  line-height: 1.4;
  flex-shrink: 0; /* 탭 영역과 분리된 고정 높이 */
}
.stock-modal #modal-latest-news a {
  color: #0b5bd3; /* 링크 톤 */
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stock-modal #modal-latest-news a:hover {
  text-decoration: underline;
}

.stock-modal #tab-news .news-item {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}
.stock-modal #tab-news .news-item:last-child {
  border-bottom: 0;
}
.stock-modal #tab-news .news-item a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: inherit;
}
.stock-modal #tab-news .news-date {
  font-size: 0.78rem;
  color: #999;
}
.stock-modal #tab-news .news-title {
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}

/* 로딩 표시 */
.stock-modal #tab-news .news-loading {
  text-align: center;
  color: #777;
  padding: 12px 0;
  font-size: 0.9rem;
}

/* 모바일 미세 조정 */
@media (max-width: 480px) {
  .stock-modal #modal-latest-news { padding: 8px 16px; }
  .stock-modal #tab-news .news-title { font-size: 0.92rem; }
}

/* ===== 한 줄 최신 뉴스 배너 ===== */
.stock-modal #modal-latest-news {
  position: relative;
  padding: 12px 24px;
  border-bottom: 1px solid #ddd;
  background: linear-gradient(90deg, #fff7e6 0%, #fff 60%);
  flex-shrink: 0;
}
.stock-modal #modal-latest-news .latest-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ad4e00;
  background: #ffe1b8;
  margin-right: 10px;
}
.stock-modal #modal-latest-news a {
  color: #0b5bd3;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stock-modal #modal-latest-news a .ext {
  opacity: 0.7;
  transition: transform .15s ease, opacity .15s ease;
}
.stock-modal #modal-latest-news a:hover .ext {
  transform: translateX(2px);
  opacity: 1;
}

.stock-modal #tab-news .news-card {
  position: relative;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e6e6e6;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  padding: 12px 14px 12px 14px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stock-modal #tab-news .news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  border-color: #d8d8d8;
}
.stock-modal #tab-news .news-card a {
  text-decoration: none;
  color: inherit;
  display: block;
}
.stock-modal #tab-news .nc-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.stock-modal #tab-news .nc-date {
  font-size: 0.78rem;
  color: #888;
}
.stock-modal #tab-news .nc-new {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b80000;
  background: #ffe0e0;
}
.stock-modal #tab-news .nc-title {
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.35;
  color: #222;
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* 두 줄로 자르기 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stock-modal #tab-news .nc-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: #666;
}
.stock-modal #tab-news .nc-open {
  margin-left: auto;
  color: #0b5bd3;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: .85;
  transition: opacity .15s ease, transform .15s ease;
}
.stock-modal #tab-news .news-card:hover .nc-open {
  opacity: 1;
  transform: translateX(1px);
}

/* 로딩 텍스트 */
.stock-modal #tab-news .news-loading {
  text-align: center;
  color: #777;
  padding: 10px 0;
  font-size: 0.9rem;
}

/* 모바일 미세조정 */
@media (max-width: 480px) {
  .stock-modal #modal-latest-news { padding: 10px 16px; }
  .stock-modal #tab-news .news-card { padding: 10px 12px; }
  .stock-modal #tab-news .nc-title { font-size: 0.95rem; }
}

/* 한 줄 뉴스 (상단 배너) */
#modal-latest-news {
  text-align: center;     /* 가운데 정렬 */
  padding: 10px 16px;
  background: #fefefe;
  border-bottom: 1px solid #ddd;
  font-weight: 600;
  font-size: 0.95rem;
}

#modal-latest-news a {
  color: #333d4b;
  text-decoration: none;
}

#modal-latest-news a:hover {
  text-decoration: underline;
}

#modal-latest-news .ext {
  margin-left: 6px;
  font-size: 0.9rem;
  color: #888;
}

/* 한 줄 뉴스 (상단 배너) */
#modal-latest-news {
  text-align: center;
  padding: 10px 16px;
  background: #f9fafc;
  border-bottom: 1px solid #ddd;
  font-weight: 500;
  font-size: 0.95rem;
}

#modal-latest-news .label {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #333d4b;   /* 어두운 배경 */
  border-radius: 4px;
}

#modal-latest-news a {
  color: #333d4b;
  text-decoration: none;
  font-weight: 600;
}

#modal-latest-news a:hover {
  text-decoration: underline;
}

#modal-latest-news .ext {
  margin-left: 6px;
  font-size: 0.9rem;
  color: #888;
}

#modal-latest-news .time {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: #666;
}

#modal-latest-news {
  text-align: center;
  padding: 10px 16px;
  background: #f9fafc;
  border-bottom: 1px solid #ddd;
  font-size: 0.95rem;
}

#modal-latest-news .label {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #333d4b;
  border-radius: 4px;
}

#modal-latest-news a {
  color: #333d4b;
  text-decoration: none;
  font-weight: 600;
}

#modal-latest-news a:hover {
  text-decoration: underline;
}

#modal-latest-news .nl-title {
  margin: 0 6px;
}

#modal-latest-news .nl-time {
  font-size: 0.8rem;
  color: #666;
  margin-left: 4px;
}

#modal-latest-news .ext {
  margin-left: 6px;
  font-size: 0.9rem;
  color: #888;
}

#modal-latest-news .nl-time { margin-left: 6px; }

/* ── 종목 메모 카드 ── */
.stock-modal .memo-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  padding: 16px;
  border: 1px solid #ddd;
}

.stock-modal .memo-card .memo-header {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333d4b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stock-modal .memo-card .memo-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #444;
  white-space: pre-wrap;
  word-break: break-word;
}

/* === 모바일 최적화 추가 === */
@media (max-width: 480px) {
  /* 탭 버튼 폰트 줄이기 */
  .stock-modal .modal-tabs .tab-btn {
    font-size: 0.85rem;   /* 기존 1rem → 작게 */
    padding: 10px 0;      /* 세로 여백도 살짝 줄임 */
  }

  /* 한줄 뉴스 텍스트 줄이기 */
  #modal-latest-news .nl-title {
    font-size: 0.85rem;   /* 기본보다 작게 */
  }
  #modal-latest-news .nl-time {
    font-size: 0.75rem;   /* 시간도 더 작게 */
  }
}


@media (min-width: 1023px) {

/* ── 테마 이슈: 카드 컨테이너 ── */
.stock-modal .history-cards {
  display: flex;
  flex-direction: column; /* 한 줄에 하나씩 */
  gap: 16px;
  padding: 0 24px;
}

/* ===== 뉴스 탭: 카드 뷰 ===== */
.stock-modal #tab-news .news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0 24px;
  list-style: none;
}
}

@media (max-width: 1023px) {

/* ── 테마 이슈: 카드 컨테이너 ── */
.stock-modal .history-cards {
  display: flex;
  flex-direction: column; /* 한 줄에 하나씩 */
  gap: 16px;
}

/* ===== 뉴스 탭: 카드 뷰 ===== */
.stock-modal #tab-news .news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  list-style: none;
  padding: 0;
}

#modal-latest-news .nl-title {
  margin: 0;
}

.stock-modal #modal-latest-news a {
  gap: 1px;
}
}