/*
 * =========================================================================================
 * [비즈니스 로직 요약]
 * - AllDayStock 일일 시황 대시보드(main.html) 및 일자별 시황 리포트(market_YYYYMMDD.html) 전용 스타일시트입니다.
 * - 마켓 펄스 칩(KOSPI, KOSDAQ, ETF, 환율), Gemini AI 시황 브리핑 카드, 상승률 TOP 10 탭,
 *   투자자별 수급 동향, 업종/테마 동향, 3대 리포트 바로가기 카드의 반응형 레이아웃 및 테마를 정의합니다.
 *
 * [핵심 요구사항 리스트]
 * 1. 메인 시황 전용 스타일 외부 파일화 (/assets/css/market.css) 및 브라우저 캐싱 최적화
 * 2. [요구사항 7 개선] 상승률 TOP 10 등락 컬럼(.up-rate)의 붉은색(#e11d48) 시각적 강조 및 가독성 확보
 * 3. 마켓 펄스 지표 칩 그리드 및 변동률 색상 시스템 (상승: #e11d48, 하락: #2563eb, 보합: muted)
 * 4. Google Material Symbols Outlined 공식 웹폰트와 연동된 아이콘 및 태그 뱃지 스타일링
 * 5. 모바일/태블릿(max-width: 768px) 완벽 대응 반응형 미디어 쿼리
 * =========================================================================================
 */

/* 1. 메인 레이아웃 및 래퍼 */
.main-wrapper {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  width: 100%;
}

/* 2. 히어로 및 마켓 펄스 섹션 */
.hero-section {
  background: linear-gradient(135deg, rgba(16, 124, 65, 0.08) 0%, rgba(37, 99, 235, 0.06) 100%);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 36px 32px 28px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.hero-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.badge-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.date-label {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* 기준일자 달력 선택 툴바 */
.date-selector-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  padding: 8px 18px;
  border-radius: 26px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.date-selector-bar:hover, .date-selector-bar:focus-within {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.date-label-icon {
  display: flex;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  gap: 6px;
  cursor: pointer;
}

.date-input-field {
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.date-input-field:focus {
  border-color: var(--primary-color);
  background-color: var(--card-bg);
}

.hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 8px 0 8px;
  letter-spacing: -0.02em;
}

.hero-title span {
  background: linear-gradient(135deg, var(--primary-color), #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  max-width: 780px;
  line-height: 1.6;
}

/* 마켓 펄스 칩스 그리드 */
.market-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.market-chip {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.market-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chip-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-icon-tag {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tag-kospi { background-color: #e11d48; }
.tag-kosdaq { background-color: #0284c7; }
.tag-etf { background-color: #107c41; }
.tag-krw { background-color: #f59e0b; }

.chip-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
}

.chip-change {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.up-rate { color: #e11d48; }
.down-rate { color: #2563eb; }
.no-rate { color: var(--text-muted); }

/* 3. 오늘의 핵심 마켓 브리핑 카드 */
.briefing-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary-color);
  border-radius: 16px;
  padding: 26px 30px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.briefing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.briefing-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.briefing-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.briefing-tag {
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.briefing-body {
  padding-top: 4px;
}

.briefing-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.briefing-summary {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-color, #2563eb);
  margin-bottom: 14px;
  line-height: 1.6;
}

.briefing-paragraphs {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.7;
}

.briefing-paragraphs p {
  margin-bottom: 10px;
}

.briefing-paragraphs p:last-child {
  margin-bottom: 0;
}

.briefing-content {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.7;
}

.briefing-content p {
  margin-bottom: 10px;
}

.briefing-content p:last-child {
  margin-bottom: 0;
}

.briefing-keypoints {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.keypoint-pill, .keypoint-chip {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

/* 생성된 마켓 인사이트 문서가 없을 때의 Empty State UI */
.empty-insight-box {
  text-align: center;
  padding: 40px 20px;
  background-color: var(--bg-color);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  margin: 10px 0;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-insight-box h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.empty-insight-box p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

.redirect-alert-box {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin: 10px 0;
}

.redirect-alert-box h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

.redirect-alert-box .target-msg {
  font-size: 1.05rem;
  color: var(--primary-color, #2563eb);
  font-weight: 600;
  margin-bottom: 20px;
}

.redirect-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: var(--card-bg);
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary-color, #2563eb);
  animation: alertPulse 1.2s infinite ease-in-out;
}

@keyframes alertPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.market-notice-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 10px;
  padding: 8px 16px;
  margin: 14px 0 4px;
  font-size: 0.9rem;
  color: var(--primary-color, #2563eb);
  font-weight: 500;
  animation: fadeIn 0.25s ease;
}

.market-notice-banner .notice-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.market-notice-banner .notice-text strong {
  font-weight: 700;
}

.notice-close-btn {
  background: none;
  border: none;
  color: var(--primary-color, #2563eb);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
  margin-left: 8px;
  transition: opacity 0.15s;
}

.notice-close-btn:hover {
  opacity: 1;
}

/* 4. 3대 분석 리포트 카드 섹션 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 4px;
}

.section-header p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

.report-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 44px;
}

.report-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.report-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.report-card.etf-theme { border-top: 4px solid #107c41; }
.report-card.kospi-theme { border-top: 4px solid #e11d48; }
.report-card.kosdaq-theme { border-top: 4px solid #0284c7; }

.card-top {
  margin-bottom: 20px;
}

.card-icon-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box-etf { background-color: rgba(16, 124, 65, 0.12); color: #107c41; }
.box-kospi { background-color: rgba(225, 29, 72, 0.12); color: #e11d48; }
.box-kosdaq { background-color: rgba(2, 132, 199, 0.12); color: #0284c7; }

.card-icon-title h4 {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-main);
}

.card-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-list li {
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.feature-list li svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.btn-etf { background-color: #107c41; color: #ffffff; }
.btn-etf:hover { background-color: #0b592e; color: #ffffff; }

.btn-kospi { background-color: #e11d48; color: #ffffff; }
.btn-kospi:hover { background-color: #be123c; color: #ffffff; }

.btn-kosdaq { background-color: #0284c7; color: #ffffff; }
.btn-kosdaq:hover { background-color: #0369a1; color: #ffffff; }

/* 5. 지식 블로그 아티클 하이라이트 */
.blog-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.blog-summary-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
  text-decoration: none;
}

.blog-summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.blog-cat-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: #10b981;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.blog-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 10px;
}

.blog-card-snippet {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.blog-read-more {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   6. [요구사항 7] 상승률 TOP 탭 (KOSPI / KOSDAQ / ETF)
   ============================================================ */
.top-stocks-section {
  margin-bottom: 36px;
}

.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}

.tab-btn {
  padding: 8px 20px;
  border: none;
  background: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.ranking-table-wrap {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.ranking-table thead th {
  background-color: var(--bg-color);
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-color);
}

.ranking-table tbody tr {
  transition: background-color 0.15s;
}

.ranking-table tbody tr:hover {
  background-color: var(--primary-light);
}

.ranking-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.ranking-table tbody tr:last-child td {
  border-bottom: none;
}

.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.82rem;
  font-family: 'Outfit', sans-serif;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.rank-n { background-color: var(--bg-color); color: var(--text-muted); }

.stock-name-cell { font-weight: 600; }
.price-cell { font-family: 'Outfit', sans-serif; font-weight: 600; }
.change-cell { font-weight: 600; font-family: 'Outfit', sans-serif; }
.volume-cell { color: var(--text-muted); font-family: 'Outfit', sans-serif; }

/*
 * [Logic Integration: 요구사항 7 개선 - 등락 컬럼 색상 시스템]
 * 테이블 td 기본 텍스트 색상(color: var(--text-main))보다 높은 선택자 우선순위를 부여하여
 * 상승(▲) 시 붉은색(#e11d48), 하락(▼) 시 파란색(#2563eb)이 확실히 적용되도록 보장합니다.
 */
.ranking-table tbody td.change-cell.up-rate,
.ranking-table tbody td.up-rate,
.change-cell.up-rate {
  color: #e11d48 !important;
  font-weight: 700;
}

.ranking-table tbody td.change-cell.down-rate,
.ranking-table tbody td.down-rate,
.change-cell.down-rate {
  color: #2563eb !important;
  font-weight: 700;
}

.ranking-table tbody td.change-cell.no-rate,
.ranking-table tbody td.no-rate,
.change-cell.no-rate {
  color: var(--text-muted);
}

/* ============================================================
   7. [요구사항 8] 투자자별 수급 동향
   ============================================================ */
.investor-flow-section {
  margin-bottom: 36px;
}

.investor-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.investor-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.investor-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.investor-card-title .market-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-kospi { background-color: #e11d48; }
.dot-kosdaq { background-color: #0284c7; }

.investor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.investor-row:last-child {
  border-bottom: none;
}

.investor-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.investor-label .inv-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.investor-label .inv-icon .material-symbols-outlined {
  font-size: 20px;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

.icon-individual { background-color: rgba(249, 115, 22, 0.12); color: #ea580c; }
.icon-foreign { background-color: rgba(37, 99, 235, 0.12); color: #2563eb; }
.icon-institution { background-color: rgba(16, 185, 129, 0.12); color: #059669; }

.section-header h3 > .material-symbols-outlined,
.briefing-header h2 > .material-symbols-outlined {
  font-size: 24px !important;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24 !important;
  vertical-align: middle;
  margin-right: 6px;
}

.investor-val {
  font-size: 1.05rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
}

/* ============================================================
   8. [요구사항 8] 업종·테마 동향
   ============================================================ */
.sector-section {
  margin-bottom: 36px;
}

.sector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.sector-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.sector-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sector-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.sector-item:hover {
  background-color: var(--primary-light);
  border-radius: 8px;
}

.sector-item:last-child {
  border-bottom: none;
}

.sector-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

.sector-rate {
  font-size: 0.92rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

/* 9. 반응형 미디어 쿼리 (모바일 및 태블릿 대응) */
@media (max-width: 768px) {
  .hero-title { font-size: 1.7rem; }
  .hero-badge-row { flex-direction: column; align-items: flex-start; }
  .market-chips-grid { grid-template-columns: 1fr 1fr; }
  .report-cards-grid { grid-template-columns: 1fr; }
  .briefing-card { padding: 20px 18px; }
  .date-selector-bar { width: 100%; justify-content: space-between; }
  .investor-cards-grid { grid-template-columns: 1fr; }
  .sector-grid { grid-template-columns: 1fr; }
  .ranking-table { font-size: 0.82rem; }
  .ranking-table thead th, .ranking-table tbody td { padding: 9px 10px; }
  .tab-btn { padding: 7px 14px; font-size: 0.82rem; }
}
