:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --bg-base: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    font-family: 'Outfit', sans-serif;
    height: 100%;
    color: var(--text-main);
    background-color: var(--bg-base);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: var(--shadow-glass);
    border-right: 1px solid var(--border);
    transition: width 0.3s var(--transition-smooth);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,0.3) 100%);
    backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    color: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.3));
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.locate-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: all 0.3s var(--transition-bounce);
    box-shadow: var(--shadow-sm);
}

.locate-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.locate-btn:active {
    transform: translateY(0);
}

.places-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.places-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.places-list::-webkit-scrollbar-track {
    background: transparent;
}
.places-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.place-item {
    padding: 18px;
    background-color: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s var(--transition-bounce);
    position: relative;
    overflow: hidden;
}

.place-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary);
    transform: scaleY(0);
    transition: transform 0.3s var(--transition-smooth);
    border-radius: 4px 0 0 4px;
}

.place-item:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.place-item.active {
    background-color: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.place-item.active::before {
    transform: scaleY(1);
}

.place-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: var(--text-main);
    transition: color 0.2s;
}

.place-item.active .place-name {
    color: var(--primary);
}

.place-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Map Styling */
.map-container {
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Subtly style the Leaflet popups */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-family: 'Outfit', sans-serif;
}
.leaflet-popup-content b {
    color: var(--primary);
    font-size: 1.1em;
}

/* Mobile Responsiveness */
@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        border-radius: 0 0 20px 20px;
    }

    .sidebar-header {
        padding: 12px 16px;
    }

    .sidebar-header h1 {
        font-size: 1.25rem;
    }
    
    .places-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 12px 16px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        align-items: flex-start; /* Avoid stretching closed items to match open ones */
    }

    .place-item {
        flex: 0 0 calc(100% - 32px); /* Leave 16px peeking on the right */
        max-width: 320px;
        scroll-snap-align: center;
        margin-bottom: 4px; /* for shadow space */
        padding: 14px;
        max-height: 55vh; /* Safe upper bound so it never overrides the map fully */
    }

    .place-desc {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .place-item.active .place-desc {
        display: block;
        -webkit-line-clamp: unset;
        line-clamp: none;
    }

    /* On mobile, active line is at the top instead of left */
    .place-item::before {
        left: 0;
        right: 0;
        top: 0;
        bottom: auto;
        width: 100%;
        height: 4px;
        transform: scaleX(0);
        border-radius: 4px 4px 0 0;
    }

    .place-item.active::before {
        transform: scaleX(1);
    }
}

/* Reviews Styling */
.place-rating {
    display: inline-block;
    color: #eab308;
    margin-left: 8px;
    font-size: 0.9em;
    letter-spacing: 2px;
}

.reviews-section {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    max-height: 35vh; /* Let the reviews section scroll, stopping the card from growing infinitely */
    overflow-y: auto;
}

.reviews-section::-webkit-scrollbar {
    width: 6px;
}
.reviews-section::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.place-item.active .reviews-section {
    display: block;
    animation: slideDown 0.3s var(--transition-bounce) forwards;
}

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

.reviews-header {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    color: var(--primary);
}

.review {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
    font-style: italic;
    background: rgba(255, 255, 255, 0.6);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.review:last-child {
    margin-bottom: 0;
}

.review-user {
    font-weight: 600;
    font-style: normal;
    color: var(--text-main);
}
