/* Warn Watch — 우측 사이드바 (단계별 4색상, 2줄 컴팩트 카드) */

.ww-aside {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

/* KOSPI / KOSDAQ 섹션을 세로로 적층, 펼친 섹션이 공간 분점 */
.ww-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.ww-section:last-child { border-bottom: none; }

/* 접힌 섹션: 헤더 높이만 차지, list/meta 숨김 */
.ww-section.is-collapsed {
  flex: 0 0 auto;
}
.ww-section.is-collapsed .ww-meta,
.ww-section.is-collapsed .ww-list { display: none; }

body.has-ww #theme-view {
  margin-right: 300px;
  max-width: none;
}

/* === 모바일: 상단 stack, flex 레이아웃 해제 (height 미정의로 collapse 방지) === */
@media (max-width: 1100px) {
  body.has-ww #theme-view { margin-right: 0; }
  .ww-aside {
    position: static;
    display: block;
    width: auto;
    max-height: none;
    border-left: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .ww-section {
    display: block;
    flex: none;
    min-height: 0;
    overflow: visible;
  }
  .ww-list {
    display: block;
    max-height: 40vh;
    overflow-y: auto;
  }
}

.ww-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff7f5;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(192, 57, 43, 0.1);
}
.ww-header:hover { background: #ffe8e0; }

.ww-arrow {
  font-size: 18px;
  font-weight: 700;
  color: #c0392b;
  line-height: 1;
}

.ww-title {
  font-size: 13px;
  font-weight: 700;
  color: #c0392b;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ww-meta {
  padding: 4px 10px;
  font-size: 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #fafbff;
  flex: 0 0 auto;
}

.ww-refresh {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  padding: 2px 7px;
  font-size: 13px;
  margin-left: auto;
}

.ww-arrow { order: 1; }
.ww-refresh { order: 2; }

.ww-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* === 카드 (2줄) === */
.ww-card {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
  line-height: 1.3;
}
.ww-card:hover { filter: brightness(1.04); }

/* === 단계별 색상 === */
/* 0 = 미발동 (임박/근접/추적) */
.ww-card.stage-0 {
  background: #f5f5f5;
  border-color: #ddd;
  color: #333;
}
/* 1 = 경고예고 (대한전선 5/7) — 노랑 */
.ww-card.stage-1 {
  background: #fff5b8;
  border-color: #f0d040;
  color: #5a4500;
}
/* 2 = 경고지정 — 주황 */
.ww-card.stage-2 {
  background: #ffba6b;
  border-color: #e67e22;
  color: #5a2a00;
}
/* 3 = 위험예고 — 빨강 */
.ww-card.stage-3 {
  background: #ff6b6b;
  border-color: #c0392b;
  color: #fff;
}
/* 4 = 위험지정/거래정지 — 진검빨강 */
.ww-card.stage-4 {
  background: #5a0e0e;
  border-color: #2a0000;
  color: #ffd5d5;
  font-weight: 600;
}
.ww-card.stage-4 .ww-pct.up,
.ww-card.stage-4 .ww-pct.down,
.ww-card.stage-3 .ww-pct.up,
.ww-card.stage-3 .ww-pct.down {
  color: inherit !important;
}

.ww-card-row1 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.ww-stage {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.15);
  color: inherit;
}

.ww-card.stage-0 .ww-stage { background: #999; color: #fff; }
.ww-card.stage-3 .ww-stage,
.ww-card.stage-4 .ww-stage { background: rgba(255, 255, 255, 0.25); color: #fff; }

.ww-name {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ww-need {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ww-card-row2 {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.ww-pct.up   { color: var(--up); }
.ww-pct.down { color: var(--down); }

.ww-empty {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
