/* Main Dashboard CSS */
* {
    box-sizing: border-box;
}

.dashboard-container {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 0;
}

/* Main Search System (Wide & Integrated) */
.main-search-section {
    width: 100%;
    margin: 20px 0 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-search-bar {
    width: 100%;
    height: 70px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    padding: 5px;
    transition: all 0.3s ease;
}

.main-search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.search-field {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 25px;
    gap: 15px;
}

.field-icon {
    font-size: 1.2rem;
    color: var(--primary-color);
    opacity: 0.8;
}

.search-field input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
    outline: none;
}

.search-field input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.search-field-divider {
    width: 1px;
    height: 35px;
    background-color: var(--border-color);
}

.main-search-submit {
    height: 58px;
    padding: 0 40px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    margin-right: 2px;
}

.main-search-submit:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.main-search-card {
    min-height: auto !important;
    margin-bottom: 25px;
}

/* Region Pills Integrated */
.main-region-pills {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
    padding: 15px 20px;
}

.region-pill {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.region-pill:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-card);
}

.region-pill.active {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
    box-shadow: var(--shadow-sm);
}

/* Sub Region Pills (SGG) */
.sub-region-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0 20px 20px;
    width: 100%;
}

/* Cleanup Hero Styles */
.search-hero-area, .search-hero-inner, .hero-main-title, .hero-search-card, .hero-search-form, .hero-input-group, .hero-divider, .hero-search-btn-text {
    display: none !important;
}

/* Remove old hero styles */
.hero-section, .main-search-container, .search-hero-title, .main-search-form, .main-search-input-group, .main-search-btn {
    display: none !important;
}
.region-selection, .region-btn, .sub-region-selection, .quick-region-filter, .sub-region-pills, .sub-pill {
    display: none !important;
}

.sub-region-btn {
    padding: 8px 10px;
    border-radius: 12px; /* 둥근 모서리 약간 감소 */
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 75px;
    position: relative; /* 배지 배치를 위한 기준점 */
    overflow: visible; /* 배지가 튀어나오도록 허용 */
}

.sgg-name-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sgg-badge {
    position: absolute;
    font-size: 0.6rem;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.badge-rank {
    top: -6px;
    left: -4px;
    background-color: #f39c12; /* 주황색: 급등 */
}

.badge-high {
    top: -6px;
    right: -4px;
    background-color: #e74c3c; /* 빨간색: 신고가 */
}

.sub-region-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sub-region-btn.active {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.sgg-cnt {
    font-size: 0.7rem;
    background: rgba(52, 152, 219, 0.15);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 800;
}

[data-theme="dark"] .sgg-cnt {
    background: rgba(52, 152, 219, 0.25);
}

.sub-region-btn.active .sgg-cnt {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.sgg-cnt.empty {
    background: var(--border-color);
    color: var(--text-muted);
}

[data-theme="dark"] .sgg-cnt.empty {
    background: rgba(255, 255, 255, 0.05);
}

/* Stat Cards Section */
.stat-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.stat-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    background: var(--bg-card);
    padding: 15px 10px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100px;
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: nowrap;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

/* Card Grid System */
.dash-card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-flow: row; /* 좌우 먼저 채우고 아래로 이동 */
    gap: 24px;
    padding: 20px;
    height: 100%;
    align-content: start;
}

.dash-card-item {
    background: var(--bg-light);
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: pointer;
    min-height: 130px;
    height: 130px; /* PC 화면에서 고정 높이 130px 부여로 범위를 절대 벗어나지 않게 강제 */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.dash-card-item:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.12);
    background: var(--bg-card);
}

.card-loc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-icon-loc {
    color: var(--primary-color);
    opacity: 0.6;
    font-size: 0.75rem;
}

.card-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-icon-title {
    color: var(--primary-color);
    opacity: 0.7;
    font-size: 0.85rem;
}

.card-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.card-price {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 1rem;
    white-space: nowrap;
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-btn-sm {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn-sm:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.fav-drag-container .dash-card-item {
    cursor: grab;
    user-select: none;
    position: relative;
}

.fav-drag-container .dash-card-item:active {
    cursor: grabbing;
}

.fav-drag-container .dash-card-item.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
}

.section-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    height: 100%; /* Ensure full height in grid cell */
}

.dashboard-grid .section-card {
    height: 841px; /* 10개 리스트 및 130px 카드 그리드 높이(786px) + 헤더(55px)와 동일화 */
    min-height: 841px;
}

.section-compare {
    margin-top: 25px !important;
    min-height: auto !important; /* Compare section doesn't need 520px min-height */
}

.section-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0,0,0,0.02);
    height: 55px; /* Fixed header height */
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.more-btn {
    font-size: 0.85rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.section-body {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Tables */
.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed; /* Fixed layout for consistency */
}

.dash-table th {
    background: var(--bg-light);
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    height: 45px;
}

.dash-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    height: 46px; /* Uniform row height */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.dash-table .price-val {
    font-weight: 700;
    text-align: right;
}

.dash-table .text-center { text-align: center; }
.dash-table .text-right { text-align: right; }

.price-up { color: #e74c3c; }
.price-down { color: #3498db; }
.price-high { color: #f39c12; font-weight: 800; }

/* Remove old specific styles */
.rising-grid, .rising-item, .rising-loc, .rising-apt, .rising-stats, .rising-rate { display: none; }

/* Compare Area */
.compare-box {
    padding: 40px;
    display: flex;
    gap: 15px;
    align-items: center;
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-light));
    border-radius: 0 0 12px 12px;
}

.compare-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.compare-input-wrapper input {
    width: 100%;
    padding: 14px 18px 14px 45px; /* Extra left padding for icon */
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.compare-input-wrapper .search-icon {
    position: absolute;
    left: 18px;
    color: var(--primary-color);
    font-size: 1.1rem;
    opacity: 0.7;
}

.compare-input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
    background: white;
    outline: none;
}

.compare-vs-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
}

.vs-circle {
    width: 42px;
    height: 42px;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--text-muted);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.compare-submit {
    padding: 14px 35px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.compare-submit:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.compare-submit:active {
    transform: translateY(0);
}

/* Mobile adjustments for compare area */
@media (max-width: 992px) {
    .compare-box {
        flex-direction: column;
        padding: 25px;
        gap: 15px;
    }
    .compare-vs-wrapper {
        padding: 5px 0;
    }
    .compare-input-wrapper, .compare-submit {
        width: 100%;
    }
    .compare-submit {
        justify-content: center;
    }
}

/* Integrated Comparison Section Design */
.compare-integrated-box {
    display: flex;
    align-items: stretch;
    padding: 30px 40px 10px;
    gap: 0;
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-light));
}

.compare-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.side-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-a, .badge-b {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 900;
}

.badge-a { background: var(--primary-color); }
.badge-b { background: #e67e22; }

.side-inputs {
    display: flex;
    gap: 10px;
}

.input-with-icon {
    position: relative;
    flex: 1;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    opacity: 0.6;
    font-size: 0.9rem;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 12px 12px 35px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.input-with-icon input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
}

.compare-vs-center {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.vs-glow {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text-muted);
    background: var(--bg-light);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
    z-index: 2;
}

.compare-action-area {
    padding: 20px 40px 40px;
    text-align: center;
    background: var(--bg-light);
    border-radius: 0 0 12px 12px;
}

.compare-submit-btn {
    width: 100%;
    max-width: 500px;
    padding: 16px;
    border-radius: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.compare-submit-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* Mobile Integrated Comparison */
.m-compare-integrated {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.m-compare-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.m-side-label {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.m-input-with-icon {
    position: relative;
}

.m-input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    opacity: 0.6;
}

.m-input-with-icon input {
    width: 100%;
    padding: 12px 12px 12px 35px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-light);
    font-size: 0.9rem;
}

.m-vs-divider {
    text-align: center;
    position: relative;
    margin: 5px 0;
}

.m-vs-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: var(--border-color);
    z-index: 1;
}

.m-vs-divider span {
    background: var(--bg-card);
    padding: 0 15px;
    position: relative;
    z-index: 2;
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.m-compare-btn {
    margin-top: 10px;
    padding: 15px;
    border-radius: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    font-weight: 800;
    font-size: 1rem;
}

/* Autocomplete */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 2000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.ac-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.ac-item:hover {
    background-color: var(--bg-light);
}

.ac-item .type-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--border-color);
}

/* Popular Areas */
.popular-section {
    margin-top: 30px;
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.popular-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.popular-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.popular-card .name {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Weekly Popular Trades container & item styles for precise height alignment */
.popular-trades-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    height: 100%;
}

.popular-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 12px;
    transition: all 0.2s;
    cursor: pointer;
    height: 62px; /* 841px 전체 대시보드 높이에 맞추어 (패딩 40px 제외한 746px 가용 공간에 10개 배치) 62px로 재조정 */
}

.popular-item:hover {
    border-color: var(--primary-color) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
}

/* Mobile Adjustments */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .popular-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid .section-card {
        height: auto !important;
        min-height: auto !important;
    }
    .dash-card-item {
        height: auto !important;
        min-height: 120px !important;
    }
    /* On mobile, reset fixed height and extra padding to save screen space */
    .popular-trades-container {
        padding: 15px;
        gap: 10px;
    }
    .popular-item {
        height: auto;
        padding: 12px 15px;
    }
}

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

/* Interactive SVG Map Styles */
.map-svg-element {
    width: 100%;
    height: 100%;
    max-height: 480px;
    display: block;
}

.map-region-path {
    stroke: var(--bg-card);
    stroke-width: 1.5;
    stroke-linejoin: round;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

.map-region-path:hover {
    stroke: var(--primary-color);
    stroke-width: 2.5;
    filter: brightness(0.9);
}

.map-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Horizontal Bar Chart Styles for other regions */
.map-fallback-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 10px;
    overflow-y: auto;
    max-height: 700px;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.chart-bar-row:hover {
    background-color: var(--bg-light);
}

.chart-bar-label {
    width: 80px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar-container {
    flex: 1;
    height: 14px;
    background-color: var(--bg-light);
    border-radius: 7px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #7fb3d5, #2471a3);
    border-radius: 7px;
    transition: width 0.6s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.chart-bar-value {
    width: 50px;
    text-align: right;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-color);
}
