/*
 * 청약백과 - Housing Subscription Encyclopedia
 * Concept: "청약 백과사전"
 * Focus: 청약 일정 + 가이드 + 계산기 통합 정보
 */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
    /* Primary Colors */
    --primary: #3b82f6;
    /* Blue - Standard Action */
    --bg-page: #f8fafc;
    /* Slate 50 */
    --bg-card: #ffffff;

    /* Functional Status Colors */
    --status-ongoing-bg: #DCFCE7;
    --status-ongoing-text: #16A34A;

    --status-upcoming-bg: #F1F5F9;
    --status-upcoming-text: #475569;

    --status-closed-bg: #f8fafc;
    --status-closed-text: #64748b;

    --status-imminent-bg: #fef2f2;
    --status-imminent-text: #dc2626;
    /* Pure Red */

    /* Announcement (안내문) - 구분을 위한 점선 스타일 */
    --status-announcement-bg: #fefce8;
    --status-announcement-text: #a16207;

    /* Typography Colors */
    --text-main: #0f172a;
    /* Slate 900 */
    --text-sub: #475569;
    /* Slate 600 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    /* Borders & Shadows */
    --border: #e2e8f0;
    /* Slate 200 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 15px;
}

.container {
    max-width: 1200px;
    /* Wider for two-column layout */
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* ===== Two Column Layout ===== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

.main-left {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 24px;
}

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

    .main-right {
        position: static;
    }
}

/* ===== Header Area ===== */
.summary-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}


/* Logo Area */
.logo-area {
    display: flex;
    flex-direction: column;
}

.summary-header h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.site-tagline {
    font-size: 13px;
    color: var(--text-sub);
    margin-top: 2px;
    font-weight: 500;
}

.guide-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: 1px solid var(--primary);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.guide-link:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.guide-link .stat-label {
    color: rgba(255, 255, 255, 0.9);
}

.guide-link .stat-value {
    color: #ffffff;
}

.summary-stats {
    display: flex;
    gap: 12px;
}

.stat-box {
    background: var(--bg-page);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 600;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
}

.stat-value.ongoing {
    color: var(--status-ongoing-text);
}

.stat-value.upcoming {
    color: var(--status-upcoming-text);
}


/* ===== Filter Bar ===== */
.filter-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 24px;
    box-shadow: var(--shadow-sm);
}

.filter-toggle {
    background: none;
    border: none;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    font-size: 15px;
}

.filter-content {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
    gap: 16px;
}

.filter-content.open {
    display: flex;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
}

.filter-group select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-page);
    cursor: pointer;
}

.filter-group select:hover {
    border-color: var(--text-muted);
}

.filter-reset {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-page);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}

.filter-reset:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
    background: var(--bg-card);
}


/* ===== Calendar Dashboard ===== */
.calendar-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.calendar-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
}

.calendar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.calendar-grid {}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
}

.calendar-weekdays span {
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-sub);
}

.calendar-weekdays span:first-child {
    color: #dc2626;
}

/* Sun */
.calendar-weekdays span:last-child {
    color: var(--primary);
}

/* Sat */

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--border);
    /* Grid lines */
    gap: 1px;
}

.calendar-day {
    background: var(--bg-card);
    min-height: 100px;
    /* Big enough for content */
    padding: 8px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.calendar-day:hover {
    background: #f1f5f9;
}

.calendar-day.empty {
    background: #f8fafc;
    cursor: default;
}

.calendar-day.selected {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px var(--primary);
}

/* Date Number */
.day-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.day-number {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-sub);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendar-day.today .day-number {
    background: #9ca3af !important;
    color: #ffffff !important;
    font-weight: 700;
}

.calendar-day.sunday .day-number {
    color: #dc2626;
}

/* Badges Container */
.day-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

/* The numeric count chip */
.count-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.count-chip.ongoing {
    background: var(--status-ongoing-bg);
    color: var(--status-ongoing-text);
}

.count-chip.upcoming {
    background: var(--status-upcoming-bg);
    color: var(--status-upcoming-text);
}

.count-chip.announcement {
    background: var(--status-announcement-bg);
    color: var(--status-announcement-text);
}


/* ===== Detail View ===== */
.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.detail-header {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.detail-header h3 {
    font-size: 18px;
    color: var(--text-main);
}

/* List Items */
.detail-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.subscription-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    cursor: pointer;
}

.subscription-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.subscription-item:hover .item-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

.item-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-badges {
    display: flex;
    gap: 8px;
}

.item-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.item-badge.ongoing {
    background: var(--status-ongoing-bg);
    color: var(--status-ongoing-text);
}

.item-badge.upcoming {
    background: var(--status-upcoming-bg);
    color: var(--status-upcoming-text);
}

.item-badge.closed {
    background: var(--status-closed-bg);
    color: var(--status-closed-text);
}

.item-badge.imminent {
    background: var(--status-imminent-bg);
    color: var(--status-imminent-text);
}

.item-badge.announcement {
    background: var(--status-announcement-bg);
    color: var(--status-announcement-text);
}

.new-badge {
    background: #f97316;
    color: #ffffff;
    font-weight: 700;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.item-qual {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
}


.item-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.item-meta {
    font-size: 13px;
    color: var(--text-sub);
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    border: none;
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    cursor: pointer;
    transition: all 0.2s;
    vertical-align: middle;
    position: relative;
    top: 1px;
}

.info-icon:hover {
    background: var(--primary);
    color: white;
}

/* 요약 팝업 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.popup-box {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.popup-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    line-height: 1.4;
}

.popup-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 16px;
}

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

.popup-label {
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 50px;
}

.popup-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
    word-break: keep-all;
}

.popup-close {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    background: var(--text-main);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* 안내 말풍선 */
.icon-tooltip {
    position: absolute;
    background: var(--text-main);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    font-size: 13px;
    white-space: nowrap;
    animation: tooltipFade 0.3s ease;
}

.icon-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 70px;
    width: 12px;
    height: 12px;
    background: var(--text-main);
    transform: rotate(45deg);
}

.tooltip-close {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 0;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
}

.tooltip-close:hover {
    color: white;
}

@keyframes tooltipFade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.item-period {
    font-size: 12px;
    color: var(--text-sub);
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.item-arrow {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.2s, color 0.2s;
}


/* Mobile Response */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .summary-header {
        flex-direction: column;
        gap: 16px;
        align-items: center;
        padding: 20px 16px;
    }

    .logo-area {
        text-align: center;
        align-items: center;
    }

    .summary-header h1 {
        font-size: 20px;
    }

    .site-tagline {
        font-size: 12px;
    }

    .summary-stats {
        width: 100%;
        justify-content: space-between;
    }

    .stat-box, .guide-link {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-value {
        font-size: 16px;
    }

    .calendar-day {
        min-height: 70px;
        /* Smaller on mobile but keeping density */
    }

    .count-chip {
        padding: 2px;
        font-size: 10px;
        justify-content: center;
    }

    .chip-text {
        display: none;
    }

    /* Hide text "접수" on mobile if too cramped */

    .subscription-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .item-right {
        align-items: flex-start;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Guide Section */
.guide-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.guide-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.guide-section-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #0369a1;
    margin: 0;
}

.view-all-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.view-all-link:hover {
    text-decoration: underline;
}

.guide-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e0f2fe;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s;
}

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

.guide-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.guide-card-desc {
    font-size: 12px;
    color: var(--text-sub);
}

/* Tool Card - 계산기/도구용 강조 스타일 */
.guide-card.tool-card {
    background: #ffffff;
    border-color: #a5b4fc;
}

.guide-card.tool-card:hover {
    border-color: #6366f1;
}

.guide-card.tool-card .guide-card-title {
    color: #3730a3;
}

@media (max-width: 900px) {
    .guide-section {
        order: -1;
    }

    .guide-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .guide-card {
        text-align: center;
        align-items: center;
    }

    .guide-card:hover {
        transform: translateY(-2px);
    }
}

@media (max-width: 500px) {
    .guide-cards {
        grid-template-columns: 1fr;
    }

    .guide-card {
        text-align: left;
        align-items: flex-start;
    }
}

/* Ad Banner */
.ad-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    min-height: 100px;
}

/* Source Banner */
.source-banner {
    padding: 16px 20px;
    margin-top: 40px;
    margin-bottom: 24px;
    text-align: center;
}

.source-header {
    margin-bottom: 12px;
}

.source-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-sub);
}

.source-links {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.source-link {
    background: var(--bg-page);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.15s;
}

.source-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.source-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* Contact Section */
.contact-section {
    text-align: center;
    padding: 16px;
    margin-bottom: 24px;
}

.contact-text {
    font-size: 13px;
    color: var(--primary);
}

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

/* Guide/Tool Page Common Styles */
.tool-container,
.guide-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.tool-container .calc-section,
.tool-container .result-box,
.tool-container .tip-box,
.tool-container .region-info,
.tool-container .score-breakdown,
.guide-container .guide-section-content {
    margin-left: 0;
    margin-right: 0;
}

@media (max-width: 600px) {
    .tool-container,
    .guide-container {
        padding: 16px;
    }

    .tool-container .calc-section,
    .guide-container .guide-section-content {
        padding: 16px;
        margin: 0 0 16px 0;
    }

    .tool-container .tip-box {
        margin: 0 0 16px 0;
        padding: 14px 16px;
    }

    .tool-container .region-info {
        margin: 16px 0;
        padding: 14px 16px;
    }
}