/* static/css/theme_modal.css */

/* ── Theme Modal ── */
.theme-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.theme-modal.hidden {
    display: none;
}

/* Overlay */
.theme-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

/* Card */
.theme-modal .modal-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header & Close (reuse stock-modal styles) */
.theme-modal .modal-header { /* same as stock-modal */
}

.theme-modal .modal-close { /* same as stock-modal */
}

/* ── 통계 영역 ── */
.theme-modal .modal-stats {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.theme-modal .modal-stats .stat-item {
    flex: 1;
    background: #fff;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}

.theme-modal .modal-stats .stat-label {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 4px;
}

.theme-modal .modal-stats .stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333d4b;
}

.theme-modal .modal-stats .stat-value.positive {
    color: #e71909;
}

.theme-modal .modal-stats .stat-value.negative {
    color: #115bcb;
}

/* ── Tabs ── */
.theme-modal .modal-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin: 0 24px;
    flex-shrink: 0;
}

.theme-modal .tab-btn {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.theme-modal .tab-btn.active {
    color: #333d4b;
    border-bottom-color: rgba(51, 61, 75, 0.7);
    font-weight: 600;
}

/* ── Tab Panels ── */
.theme-modal .tab-panel {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
}

.theme-modal .tab-panel.hidden {
    display: none;
}

.theme-modal .issue-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;
}

.theme-modal .issue-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.theme-modal .hc-date {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 8px;
}

.theme-modal .hc-comment {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 12px;
}

.theme-modal .hc-stocks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.theme-modal .hc-stock-btn {
    background: #f5f5f5;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.theme-modal .hc-stock-btn:hover {
    background: #e0e0e0;
}

.theme-modal .hc-stock-btn .stock-name {
    color: #333;
}

.theme-modal .hc-stock-btn .hc-change {
    font-weight: 700;
}

.theme-modal .hc-stock-btn .hc-change.positive {
    color: #e71909;
}

.theme-modal .hc-stock-btn .hc-change.negative {
    color: #115bcb;
}


.theme-modal .stock-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;
}

.theme-modal .stock-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* 첫 줄: 종목명과 등락률 */
.theme-modal .stock-card .sc-line1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.theme-modal .stock-card .sc-name {
    font-size: 1rem;
    font-weight: 600;
    color: #333d4b;
}

.theme-modal .stock-card .sc-change {
    font-size: 1.1rem;
    font-weight: 700;
}

.theme-modal .stock-card .sc-change.positive {
    color: #e71909;
}

.theme-modal .stock-card .sc-change.negative {
    color: #115bcb;
}

/* 둘째 줄: 코드와 거래대금 */
.theme-modal .stock-card .sc-line2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #777;
}

.theme-modal .stock-card .sc-code {
}

.theme-modal .stock-card .sc-value {
}

/* ── Related Stocks: 2줄 레이아웃 수정 ── */
.theme-modal .stock-card .sc-line1,
.theme-modal .stock-card .sc-line2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* 혹시 버튼이나 부모가 text-align:center 여서 중앙 정렬되면 해제 */
.theme-modal .stock-card {
    text-align: left;
}

.theme-modal .sort-btn {
    flex: none;
    padding: 4px 12px;
    border: none;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.theme-modal .sort-btn.active {
    background: #333d4b;
    color: #fff;
}

/* 카드에 테두리 추가 */
.theme-modal .issue-card,
.theme-modal .stock-card {
    border: 1px solid #ddd;
}

/* hover 시 강조색으로 변경 */
.theme-modal .issue-card:hover,
.theme-modal .stock-card:hover {
    border-color: #ccc;
}

@media (min-width: 1023px) {
    /* ── Issue Cards ── */
    .theme-modal .issue-cards {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0 24px;
    }

    /* ── Related Stocks ── */
    .theme-modal .stock-cards {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0 24px;
    }

  .theme-modal .stock-sort-toggle {
      display: flex;
      gap: 8px;
      padding: 0 24px 8px;
  }

}

@media (max-width: 1023px) {
    /* ── Issue Cards ── */
    .theme-modal .issue-cards {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* ── Related Stocks ── */
    .theme-modal .stock-cards {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

  .theme-modal .stock-sort-toggle {
      display: flex;
      gap: 8px;
      padding-bottom: 8px;
  }
  .theme-modal .modal-stats .stat-value {
    font-size: 1rem;
  }
  .theme-modal .tab-btn {
    font-size: 0.85rem;
  }
}
/* ═══════════════════════════════════════════════════════════
   모바일 테마 모달 = 바텀시트 (≤1023px)
   종목 모달과 같은 규칙 — 손잡이 · 흰 헤더(테마명 + 상승/하락 배지) ·
   회색 통계 박스 · 세그먼트 탭 · 날짜/등락률 한 줄 이슈 카드
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
    .theme-modal { align-items: flex-end; }

    .theme-modal .modal-card {
        width: 100%;
        max-width: none;
        height: auto;
        max-height: 88vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(11, 14, 19, .2);
    }

    .theme-modal .sheet-grab {
        display: block;
        flex: none;
        width: 38px; height: 4px;
        margin: 10px auto 2px;
        border-radius: 99px;
        background: #e0e3e8;
    }

    /* ── 헤더 ── */
    .theme-modal .modal-header {
        background: #fff;
        color: #1b2330;
        align-items: flex-start;
        gap: 10px;
        padding: 8px 16px 12px;
    }
    .theme-modal .modal-head-text { flex: 1; min-width: 0; }
    .theme-modal .modal-header h2 {
        font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em;
        color: #1b2330;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    /* 상승/하락 종목 수 배지 */
    .theme-modal .modal-updown { display: flex; gap: 5px; margin-top: 6px; }
    .theme-modal .modal-updown:empty { display: none; }
    .theme-modal .modal-updown .ud {
        padding: 2px 8px; border-radius: 6px;
        font-size: .7rem; font-weight: 700;
    }
    .theme-modal .modal-updown .ud.up { background: #fdecea; color: #e71909; }
    .theme-modal .modal-updown .ud.down { background: #eaf2fd; color: #115bcb; }

    .theme-modal .modal-close {
        flex: none;
        width: 32px; height: 32px;
        display: flex; align-items: center; justify-content: center;
        padding: 0; line-height: 1;
        border-radius: 50%;
        background: #f2f4f6; color: #4e5968;
        font-size: 1.15rem;
    }
    .theme-modal .modal-close:hover { transform: none; background: #e9ebef; }

    /* ── 통계 ── */
    .theme-modal .modal-stats {
        background: #fff; border-bottom: none;
        gap: 8px; padding: 0 16px 12px;
    }
    .theme-modal .modal-stats .stat-item {
        flex: 1; min-width: 0;
        background: #f4f5f7; border: none; border-radius: 12px;
        padding: 11px 12px; box-shadow: none;
        text-align: left;
    }
    .theme-modal .modal-stats .stat-label {
        font-size: .7rem; color: #8a94a0; font-weight: 600; margin-bottom: 3px;
    }
    .theme-modal .modal-stats .stat-value {
        font-size: 1.05rem; font-weight: 800; color: #1b2330;
        font-variant-numeric: tabular-nums;
    }
    .theme-modal .modal-stats .stat-value.positive { color: #e71909; }
    .theme-modal .modal-stats .stat-value.negative { color: #115bcb; }

    /* ── 탭: 세그먼트 ── */
    .theme-modal .modal-tabs {
        margin: 0 16px 10px;
        padding: 3px; gap: 2px;
        background: #f4f5f7; border: none; border-radius: 12px;
    }
    .theme-modal .modal-tabs .tab-btn {
        flex: 1; min-width: 0;
        padding: 8px 0; border-radius: 9px; border-bottom: none;
        font-size: .82rem; font-weight: 700; color: #8a94a0; white-space: nowrap;
    }
    .theme-modal .modal-tabs .tab-btn.active {
        background: #fff; color: #1b2330; border-bottom: none;
        box-shadow: 0 1px 3px rgba(27, 35, 48, .1);
    }

    /* ── 이슈 카드 ── */
    .theme-modal .tab-panel { padding: 0 16px 16px; }
    .theme-modal .issue-cards { gap: 8px; }

    .theme-modal .issue-card {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "date . change" "body body body" "stocks stocks stocks";
        align-items: center;
        column-gap: 7px; row-gap: 6px;
        padding: 11px 12px;
        border: 1px solid #eef0f3; border-radius: 12px;
        box-shadow: none;
    }
    .theme-modal .issue-card:hover { transform: none; box-shadow: none; }
    .theme-modal .hc-date {
        grid-area: date; margin: 0;
        font-size: .78rem; font-weight: 700; color: #e71909;
        font-variant-numeric: tabular-nums;
    }
    /* 이슈 카드 직계만 — 종목 칩(.hc-stock-btn) 안의 .hc-change 는 그대로 */
    .theme-modal .issue-card > .hc-change {
        grid-area: change;
        font-size: .88rem; font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .theme-modal .issue-card > .hc-change.positive { color: #e71909; }
    .theme-modal .issue-card > .hc-change.negative { color: #115bcb; }
    .theme-modal .hc-comment {
        grid-area: body; margin: 0;
        font-size: .82rem; line-height: 1.6; color: #3f4a58;
    }
    .theme-modal .hc-stocks { grid-area: stocks; margin: 0; gap: 6px; }
    .theme-modal .hc-stock-btn {
        background: #f4f5f7; border-radius: 99px; padding: 4px 9px;
        font-size: .72rem; font-weight: 700; color: #1b2330;
    }
}
