/* ============================================================
   PinKids — 메인 스타일시트
   모바일 퍼스트 (375px) + PC 반응형 (768px+)
   ============================================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #FF6B9D;
    --color-primary-light: #FFE0EC;
    --color-primary-dark: #E0527E;
    --color-text: #1A1A1A;
    --color-text-secondary: #666;
    --color-text-light: #999;
    --color-bg: #FFFFFF;
    --color-bg-gray: #F5F5F7;
    --color-border: #E8E8E8;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-error: #FF3B30;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --header-height: 56px;
    --filter-height: 48px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    touch-action: manipulation;
}

/* ============================================================
   Header
   ============================================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 var(--spacing-sm);
    gap: var(--spacing-sm);
}

.btn-menu, .btn-profile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    transition: background 0.2s;
}

.btn-menu:hover, .btn-profile:hover {
    background: var(--color-bg-gray);
}

.btn-menu span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--color-text);
    margin: 3px 0;
    border-radius: 1px;
}

.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    height: 40px;
    background: var(--color-bg-gray);
    border-radius: var(--radius-full);
    padding: 0 var(--spacing-sm) 0 var(--spacing-md);
    transition: background 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
    background: var(--color-bg);
    box-shadow: 0 0 0 2px var(--color-primary);
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--color-text);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--color-text-light);
}

.btn-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-secondary);
}

/* ============================================================
   Map
   ============================================================ */
.map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: var(--filter-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10;
    border-bottom: 1px solid var(--color-border);
}

.filter-scroll {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 var(--spacing-sm);
    gap: var(--spacing-xs);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg);
    font-size: 13px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.filter-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.filter-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.filter-chip.baby-toggle {
    font-weight: 600;
    border-width: 2px;
}

.filter-chip.baby-toggle.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

.filter-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    flex-shrink: 0;
    margin: 0 4px;
}

/* ============================================================
   Place List (Bottom Sheet)
   ============================================================ */
.place-list {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background: var(--color-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    transition: height 0.3s ease, transform 0.3s ease;
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
}

.place-list.expanded {
    height: calc(100vh - var(--header-height) - var(--filter-height));
    border-radius: 0;
}

.place-list.collapsed {
    transform: translateY(100%);
}

/* 내 위치 버튼 */
.btn-my-location {
    position: fixed;
    bottom: calc(60px + var(--safe-bottom));
    left: 16px;
    z-index: 55;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-primary);
}

.btn-my-location:active {
    background: var(--color-bg-gray);
}

/* 목록 열기 버튼 */
.btn-open-list {
    display: none;
    position: fixed;
    bottom: calc(16px + var(--safe-bottom));
    left: 16px;
    z-index: 60;
    padding: 10px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
}

.btn-open-list.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.place-list-drag {
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.place-list-handle {
    width: 36px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 10px auto 0;
}

.place-list-header {
    padding: var(--spacing-sm) var(--spacing-md);
}

.place-list-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.place-list-items {
    overflow-y: auto;
    height: calc(100% - 50px);
    padding: 0 var(--spacing-md);
    -webkit-overflow-scrolling: touch;
}

/* Place Card */
.place-card {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--color-bg-gray);
    cursor: pointer;
    transition: background 0.2s;
}

.place-card:hover {
    background: var(--color-bg-gray);
    margin: 0 calc(-1 * var(--spacing-md));
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

.place-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--color-bg-gray);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.place-card-info {
    flex: 1;
    min-width: 0;
}

.place-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-card-address {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-card-tags {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.place-tag {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--color-bg-gray);
    color: var(--color-text-secondary);
}

.place-tag.active {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.place-tag.verified {
    background: #E8F5E9;
    color: #2E7D32;
    font-weight: 600;
}

.place-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--color-warning);
    flex-shrink: 0;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg-gray) 25%, #eee 50%, var(--color-bg-gray) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--color-bg-gray);
}

.skeleton-title {
    height: 16px;
    width: 60%;
    margin-bottom: 8px;
}

.skeleton-text {
    height: 12px;
    width: 80%;
    margin-bottom: 6px;
}

.skeleton-tags {
    height: 20px;
    width: 40%;
}

/* ============================================================
   Reload Map Button
   ============================================================ */
.btn-reload-map {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + var(--filter-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    padding: 10px 20px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-reload-map:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-reload-map.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cluster-selected {
    background: var(--color-primary);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    animation: popIn 0.2s ease;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* PC 목록 접기/펼치기 버튼 (모바일 숨김) */
.btn-toggle-panel {
    display: none;
}

@media (min-width: 768px) {
    .btn-reload-map {
        left: calc((100% - 380px) / 2);
    }

    .btn-open-list {
        display: none !important;
    }

    .btn-toggle-panel {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 50%;
        right: 380px;
        transform: translateY(-50%);
        z-index: 55;
        width: 28px;
        height: 56px;
        background: var(--color-primary);
        border: none;
        border-radius: var(--radius-sm) 0 0 var(--radius-sm);
        box-shadow: var(--shadow-sm);
        font-size: 12px;
        font-weight: 700;
        color: white;
        cursor: pointer;
        transition: right 0.3s ease;
        writing-mode: vertical-rl;
        letter-spacing: 2px;
    }

    .btn-toggle-panel:hover {
        background: var(--color-primary-dark);
    }

    .place-list.collapsed {
        transform: translateX(100%);
    }

    .place-list {
        transition: transform 0.3s ease;
    }

    .place-list.collapsed ~ .btn-toggle-panel,
    .btn-toggle-panel.panel-closed {
        right: 0;
    }
}

/* ============================================================
   Detail Card
   ============================================================ */
.btn-back {
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    padding: 4px 0;
}

.detail-card {
    padding: 0 0 var(--spacing-xl);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-bg-gray);
}

.detail-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-gray);
    border-radius: var(--radius-md);
}

.detail-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.detail-category {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 2px;
}

.detail-info {
    padding: var(--spacing-md) 0;
}

.detail-row {
    font-size: 14px;
    color: var(--color-text-secondary);
    padding: 4px 0;
}

.detail-section {
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--color-bg-gray);
}

.detail-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.detail-facilities {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.facility-tag {
    font-size: 13px;
    padding: 6px 12px;
    background: var(--color-bg-gray);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
}

.text-muted {
    font-size: 13px;
    color: var(--color-text-light);
}

.review-tip {
    font-size: 14px;
    color: var(--color-text);
    padding: 8px 12px;
    background: var(--color-bg-gray);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
}

.review-rating {
    font-size: 12px;
    color: var(--color-warning);
    margin-left: 4px;
}

.detail-actions {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--color-bg-gray);
    border-bottom: 1px solid var(--color-bg-gray);
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: var(--radius-md);
    background: var(--color-bg-gray);
    text-decoration: none;
    color: var(--color-text);
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
}

.action-btn:hover {
    background: var(--color-primary-light);
}

.action-btn span {
    font-size: 20px;
}

.detail-link {
    color: var(--color-primary);
    text-decoration: none;
}

.empty-facility {
    text-align: center;
    padding: var(--spacing-md);
    background: var(--color-bg-gray);
    border-radius: var(--radius-md);
}

.empty-facility p:first-child {
    font-size: 15px;
    margin-bottom: 4px;
}

.blog-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-bg-gray);
}

.blog-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.blog-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.blog-tab-content {
    display: none;
}

.blog-tab-content.active {
    display: block;
}

.blog-card {
    display: block;
    padding: 12px;
    margin-bottom: var(--spacing-sm);
    background: var(--color-bg-gray);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.2s;
}

.blog-card:hover {
    background: var(--color-primary-light);
}

.blog-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.blog-meta {
    font-size: 11px;
    color: var(--color-text-light);
}

.blog-more {
    display: block;
    width: 100%;
    padding: 12px;
    margin: var(--spacing-sm) 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.blog-more:hover {
    background: var(--color-primary-light);
}

.blog-more:disabled {
    color: var(--color-text-light);
    cursor: default;
}

.blog-source {
    font-size: 11px;
    color: var(--color-text-light);
    text-align: right;
    margin-top: var(--spacing-sm);
}

.blog-verified {
    border-left: 3px solid var(--color-success);
}

.blog-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: #E8F5E9;
    color: #2E7D32;
    margin-right: 4px;
    vertical-align: middle;
}

.blog-badge.baby {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.form-address {
    font-size: 14px;
    color: var(--color-text);
    padding: 10px 12px;
    background: var(--color-bg-gray);
    border-radius: var(--radius-sm);
}

.comment-item {
    font-size: 14px;
    color: var(--color-text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--color-bg-gray);
}

/* ============================================================
   PC 반응형 (768px+)
   ============================================================ */
@media (min-width: 768px) {
    .map-container {
        right: 380px;
    }

    .filter-bar {
        right: 380px;
    }

    .place-list {
        top: var(--header-height);
        left: auto;
        right: 0;
        width: 380px;
        height: auto;
        bottom: 0;
        border-radius: 0;
        border-left: 1px solid var(--color-border);
        box-shadow: none;
    }

    .place-list-handle {
        display: none;
    }

    .place-list-items {
        height: calc(100vh - var(--header-height) - 60px);
    }
}

/* ============================================================
   Install Popup (PWA 홈화면 추가)
   ============================================================ */
.install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.install-popup {
    width: 280px;
    background: white;
    border-radius: 20px;
    padding: 32px 24px 24px;
    text-align: center;
    position: relative;
    animation: popUp 0.3s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

@keyframes popUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.install-popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.install-popup-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.install-popup-title {
    display: block;
    font-size: 20px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.install-popup-desc {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.install-popup-btn {
    width: 100%;
    padding: 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.install-popup-btn:active {
    background: var(--color-primary-dark);
}

@media (min-width: 768px) {
    .install-overlay {
        display: none !important;
    }
}
