/* home.css - 메인 홈 화면 전용 스타일 */

/* =========================================
   1. 레이아웃 (Layout)
   ========================================= 
*/
.homeLayout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .homeLayout {
        grid-template-columns: 1fr;
    }
}

.home-container {
    margin-top: 24px;
    margin-bottom: 40px;
}

/* [수정] gap 제거 (카드 자체의 margin-bottom으로 간격 통일) */
.sideCol {
    display: flex;
    flex-direction: column;
    /* gap: 16px;  <-- 삭제 */
}

/* [수정] gap 제거 */
.stickySide {
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    /* gap: 16px; <-- 삭제 */
}

/* =========================================
   2. 증시 현황판 (Market Status)
   ========================================= 
*/
.market-card-wrap {
    margin-bottom: 24px;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.market-item {
    background: var(--surface-hover);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.market-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.market-value {
    font-size: 20px;
    font-weight: 800;
}

.market-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
}

/* 등락 색상 유틸리티 */
.color-up {
    color: #DC2626; /* 상승 (빨강) */
}

.color-down {
    color: #2563EB; /* 하락 (파랑) */
}

.color-text {
    color: var(--text); /* 기본 텍스트 색상 */
}

/* =========================================
   3. 카드 헤더 및 유틸리티
   ========================================= 
*/
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-with-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-my {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.btn-dimmed {
    opacity: 0.6;
}

.card-body-nopadding {
    padding: 0;
}

/* =========================================
   4. 광고 영역 (Advertisement)
   ========================================= 
*/
.ad-content-center {
    text-align: center;
}

.ad-text-title {
    font-size: 16px;
    font-weight: 700;
}

.ad-text-desc {
    font-size: 12px;
    margin-top: 4px;
}

.ad-side-title {
    font-size: 14px;
    font-weight: 700;
}

.ad-side-desc {
    font-size: 11px;
    margin-top: 4px;
}

/* =========================================
   5. 증시 캘린더 (Calendar)
   ========================================= 
*/
.eventCalendar {
    background: var(--surface);
}

.calendar-body {
    padding: 16px;
}

.calCtrl {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0;
}

/* 년도/월 박스 컨테이너 */
.calCtrl > div:first-child {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 17px;
    margin-left: 13px;
}

/* 화살표 버튼 컨테이너 */
.calCtrl > div:last-child {
    display: flex;
    align-items: center;
    gap: 4px;
}

.iconBtn {
    background-color: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 8px;
    transition: 0.2s;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.iconBtn:hover {
    background-color: var(--surface-hover);
    color: var(--primary);
    border-color: var(--line);
}

.iconBtn svg {
    width: 16px;
    height: 16px;
}

.cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 6px;
}

.cal .dow {
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    padding-bottom: 4px;
}

.cal .day {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--line);
    cursor: pointer;
    font-size: 12px;
    position: relative;
    color: var(--text);
}

.cal .day:hover {
    border-color: var(--primary);
}

.cal .day.today {
    border-color: var(--primary);
    background: var(--primary-bg);
    font-weight: 700;
}

.cal .day.sel {
    outline: 2px solid var(--primary);
    background: var(--surface);
    z-index: 1;
}

.cal .day .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    bottom: 3px;
}

.cal .day.muted {
    opacity: 0.3;
    background: var(--bg);
    border-color: transparent;
    color: var(--muted);
    pointer-events: none;
}

.eventSelectedBox {
    margin-top: 16px;
    padding: 14px;
    background: var(--surface-hover);
    border-radius: 12px;
    border: 1px solid var(--line);
    min-height: 60px;
}

.upcoming-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.upcoming-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 8px;
}

/* =========================================
   6. 공통 간격 (중요: 여기서 간격 제어)
   ========================================= 
*/
.sideList .searchItem .text-ellipsis {
    width: 100%;
    max-width: 100%;
    display: block;
}

/* 메인 영역과 사이드 영역의 간격을 20px로 동일하게 설정 */
.mainCol > .card,
.mainCol > .ad-container,
.sideCol .stickySide > .card,
.sideCol .stickySide > .ad-container {
    margin-bottom: 20px;
}

/* =========================================
   7. 커스텀 드롭다운 (Custom Select)
   ========================================= 
*/
.custom-select {
    position: relative;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

#calYear {
    width: 90px;
    height: 32px;
}

#calMonth {
    width: 70px;
    height: 32px;
}

.select-styled {
    background-color: var(--surface-hover);
    border-radius: 8px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: 0.2s;
    height: 32px;
    width: 100%;
    box-sizing: border-box;
}

.select-styled:hover,
.select-styled.active {
    background-color: var(--surface);
    box-shadow: 0 0 0 1px var(--line);
}

.select-styled::after {
    content: "";
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-color: var(--muted) transparent transparent transparent;
    margin-top: 3px;
    margin-left: auto;
}

.select-styled.active::after {
    margin-top: -3px;
    border-color: transparent transparent var(--muted) transparent;
}

.select-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    z-index: 999;
    margin-top: 4px;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 180px;
    overflow-y: auto;
    padding: 4px;
    overscroll-behavior: contain;
}

.select-options::-webkit-scrollbar {
    width: 4px;
}

.select-options::-webkit-scrollbar-track {
    background: transparent;
}

.select-options::-webkit-scrollbar-thumb {
    background-color: var(--line);
    border-radius: 10px;
}

.select-options::-webkit-scrollbar-thumb:hover {
    background-color: var(--muted);
}

html[data-theme="dark"] .select-options {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.select-options li {
    padding: 8px 10px;
    cursor: pointer;
    transition: 0.1s;
    border-radius: 4px;
    color: var(--text);
    white-space: nowrap;
    font-size: 13px;
    text-align: center;
}

.select-options li:hover {
    background-color: var(--surface-hover);
    color: var(--primary);
}

.select-options li[rel="selected"] {
    background-color: var(--primary-bg);
    color: var(--primary);
    font-weight: 800;
}