/* CSS Variables */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 380px;
    --header-height: 60px;
    --z-index-map: 1;
    --z-index-sidebar: 10;
    --z-index-ui: 20;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar (PC) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-index-sidebar);
    transition: transform 0.3s ease, width 0.3s ease;
    position: relative;
    box-shadow: var(--shadow-md);
}

.sidebar.collapsed {
    width: 0;
    border: none;
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-color);
}

.sidebar-header p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

/* Search Box */
.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--bg-secondary);
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 8px;
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.chip:hover {
    background-color: var(--bg-secondary);
}

.chip.active {
    background-color: var(--text-color);
    color: #fff;
    border-color: var(--text-color);
}

/* Place List */
.place-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.place-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    gap: 16px;
}

.place-item:hover {
    background-color: var(--bg-secondary);
}

.place-item.active {
    background-color: rgba(59, 130, 246, 0.05);
    border-left: 4px solid var(--primary-color);
}

.place-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background-color: #ddd;
    flex-shrink: 0;
}

.place-info {
    flex: 1;
    min-width: 0;
}

.place-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.place-meta span {
    display: inline-block;
}

.place-category {
    color: var(--primary-color);
    font-weight: 500;
}

.place-address {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sidebar Toggle Button (Inside Sidebar Footer) */
.sidebar-footer {
    padding: 0;
    position: absolute;
    top: 50%;
    right: -24px;
    transform: translateY(-50%);
    z-index: var(--z-index-ui);
}

.toggle-btn {
    width: 24px;
    height: 48px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    color: var(--text-light);
}

.toggle-btn:hover {
    color: var(--primary-color);
}

.sidebar.collapsed+.map-container .toggle-btn-placeholder {
    display: block;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    height: 100%;
    background-color: #eee;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom Marker Styles */
.custom-marker-container {
    padding-bottom: 14px;
    /* Needle length */
    position: relative;
    cursor: pointer;
    white-space: nowrap;
    /* 핀의 중심(파란 원) 아래 끝부분이 지도 좌표에 오도록 위치 조정 필요 */
    /* 하지만 구조상 핀 아래 침(Needle)이 있으므로, 침 끝이 좌표가 됨 */
}

.marker-head {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 2px solid #2563eb;
    /* Blue border */
    border-radius: 50px;
    padding: 3px;
    padding-right: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.marker-number {
    position: relative;
    z-index: 2;
    width: 32px;
    height: 32px;
    background-color: #2563eb;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.marker-info {
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.marker-title {
    font-weight: 700;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.2;
}

.marker-category {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
    margin-top: 1px;
}

/* Marker Needle (The stick below the circle) */
.marker-needle {
    position: absolute;
    /* Head Size Calculation:
       Number: 32px height
       Head Padding: 3px (top)
       Head Border: 2px (approx)
       So Number starts at ~5px from top
       Number center is at 5px + 16px = 21px from top
       
       Head Left Padding: 3px + Border 2px = 5px
       Number Left: 5px
       Number Center: 5px + 16px = 21px
    */
    left: 21px;
    /* Center of the number circle (approx) */
    bottom: 0;
    width: 3px;
    height: 24px;
    /* Extends up into the head to meet the number circle */
    background-color: #2563eb;
    transform: translateX(-50%);
    z-index: 1;
    /* On top of head background but below number */
}

/* Active State */
.custom-marker-container.active .marker-head {
    background-color: #2563eb;
    border-color: #1d4ed8;
    color: #fff;
    z-index: 50;
}

.custom-marker-container.active .marker-number {
    background-color: #fff;
    color: #2563eb;
}

.custom-marker-container.active .marker-title {
    color: #fff;
}

.custom-marker-container.active .marker-category {
    color: #dbeafe;
    /* Light blue text */
}

.custom-marker-container.active .marker-needle {
    background-color: #1d4ed8;
}

/* Mobile Toggle Button */
.mobile-list-toggle {
    display: none;
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-index-ui);
    cursor: pointer;
    align-items: center;
    gap: 8px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40vh;
        /* 초기 높이 */
        max-height: 90vh;
        border-right: none;
        border-top: 1px solid var(--border-color);
        transform: translateY(100%);
        /* 기본적으로 숨김 */
        transition: transform 0.3s ease-in-out;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
        border-radius: 20px 20px 0 0;
    }

    .sidebar.mobile-active {
        transform: translateY(0);
    }

    .sidebar.collapsed {
        width: 100%;
        transform: translateY(100%);
    }

    .sidebar-footer {
        display: none;
        /* PC용 사이드바 토글 숨김 */
    }

    .map-container {
        width: 100%;
        height: 100%;
    }

    .mobile-list-toggle {
        display: flex;
    }

    /* Mobile Header within Sidebar */
    .sidebar-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 16px;
    }

    /* Mobile Handle for dragging (Visual cue) */
    .sidebar-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background-color: #ddd;
        border-radius: 2px;
        margin: 0 auto 16px auto;
    }
}

/* Detail Popup (Card Style) */
.detail-popup {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 280px;
    /* overflow: hidden; Removed to allow arrow */
    font-family: 'Pretendard', sans-serif;
    position: relative;
    padding-bottom: 0;
}

.popup-img-container {
    height: 140px;
    background-color: #f3f4f6;
    background-image: url('https://via.placeholder.com/280x140?text=No+Image');
    background-size: cover;
    background-position: center;
    position: relative;
    border-radius: 12px 12px 0 0;
    /* Add radius manually */
}

.popup-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.popup-content {
    padding: 16px;
}

.popup-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-category {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.popup-address {
    font-size: 13px;
    color: #4b5563;
    display: flex;
    align-items: start;
    gap: 6px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.popup-actions {
    display: flex;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
    /* Add radius manually */
}

.popup-action-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 0;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-right: 1px solid #e5e7eb;
}

.popup-action-btn:first-child {
    border-bottom-left-radius: 12px;
}

.popup-action-btn:last-child {
    border-right: none;
    border-bottom-right-radius: 12px;
}

.popup-action-btn:hover {
    background-color: #f9fafb;
}

.popup-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    margin-bottom: 2px;
}

.icon-roadview {
    background-color: #fbbf24;
}

/* Yellow */
.icon-navi {
    background-color: #f59e0b;
}

/* Orange */
.icon-tmap {
    background-color: #2563eb;
    font-weight: bold;
}

/* Blue */

/* Popup Arrow */
.detail-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    /* Arrow height */
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    display: block;
}