:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #14b8a6;
    --accent: #f59e0b;
    --bg-dark: #0f172a;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.sidebar {
    width: 400px;
    height: 100%;
    background: var(--glass-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    overflow: hidden;
}

.map-container {
    flex-grow: 1;
    height: 100%;
    z-index: 1;
    background: #e2e8f0;
    /* Fallback color */
}

.header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.4));
}

.header h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--text-dark);
    line-height: 1.2;
}

.header .highlight {
    color: var(--primary);
}

.header p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.controls {
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    max-height: 44vh;
    overflow-y: auto;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.filter-actions {
    display: flex;
    gap: 0.35rem;
}

.county-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #e0f2fe;
    color: var(--primary-dark);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
}

.filter-actions button {
    border: none;
    background: transparent;
    color: var(--primary-dark);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.15rem 0.25rem;
}

.county-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.county-filters.collapsed {
    display: none;
}

.county-group.counties-collapsed .filter-actions {
    display: none;
}

.chip {
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text-dark);
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.2);
}

.list-summary {
    padding: 0.75rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
    color: var(--text-light);
}

select,
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-dark);
    transition: all 0.2s;
    outline: none;
}

select:focus,
input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.input-wrapper input {
    flex: 1;
}

.input-wrapper button {
    padding: 0 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.input-wrapper button:hover {
    background: var(--primary-dark);
}

.search-wrapper button {
    flex: 0 0 44px;
    background: #e2e8f0;
    color: var(--text-light);
}

.search-wrapper button:hover {
    background: #cbd5e1;
    color: var(--text-dark);
}

.bath-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f1f5f9;
}

.bath-card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.bath-card:hover,
.bath-card.active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.bath-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.bath-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.bath-tag {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #f1f5f9;
    border-radius: 6px;
    color: var(--text-light);
    font-weight: 500;
}

.bath-tag i {
    color: var(--primary);
}

.bath-tag.price-tag i {
    color: var(--secondary);
}

.bath-tag.rating-tag {
    background: #fffbeb;
    color: #b45309;
}

.bath-tag.rating-tag i {
    color: var(--accent);
}

.bath-tag.verified-tag {
    background: #ecfdf5;
    color: #047857;
}

.bath-tag.verified-tag i {
    color: #059669;
}

.bath-card .description {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    background: white;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    color: var(--text-light);
    padding: 2rem 1.25rem;
    text-align: center;
}

.empty-state i {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

.empty-state h3 {
    color: var(--text-dark);
    font-family: var(--font-heading);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.45;
}

/* Leaflet Popup Override */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.5;
    min-width: 260px;
}

.popup-content {
    padding: 1rem;
}

.popup-content h3 {
    font-family: var(--font-heading);
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.popup-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.popup-row i {
    width: 24px;
    text-align: center;
    color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        height: 100dvh;
        /* Use dynamic viewport height for mobile browsers */
    }

    .app-container {
        flex-direction: column;
        height: 100dvh;
    }

    .sidebar {
        width: 100%;
        height: 0;
        /* Force flex-grow to determine height */
        flex: 1 1 auto;
        order: 2;
        min-height: 0;
    }

    .header {
        padding: 1rem 1.15rem 0.85rem;
    }

    .header h1 {
        font-size: 1.45rem;
    }

    .header p {
        font-size: 0.82rem;
    }

    .controls {
        padding: 0.75rem 1rem;
        max-height: 36dvh;
    }

    .control-group {
        margin-bottom: 0.75rem;
    }

    .filter-heading {
        align-items: flex-start;
        gap: 0.5rem;
        display: block;
    }

    .county-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-left: 0;
        margin-top: 0.35rem;
        white-space: nowrap;
        width: 100%;
    }

    .filter-actions {
        flex: 0 0 auto;
    }

    .map-container {
        height: 30vh;
        height: 30dvh;
        order: 1;
        flex: 0 0 30dvh;
        /* Fixed height, no grow/shrink */
    }

    .county-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .county-filters.collapsed {
        display: none;
    }

    .county-group.counties-collapsed .filter-actions {
        display: none;
    }

    .county-filters::-webkit-scrollbar {
        height: 6px;
    }

    .county-filters::-webkit-scrollbar-thumb {
        background: #cbd5f5;
        border-radius: 999px;
    }

    .list-summary {
        padding: 0.6rem 1rem;
        font-size: 0.82rem;
    }

    .bath-list {
        padding: 0.75rem;
        gap: 0.65rem;
    }

    .bath-card {
        border-radius: 14px;
        padding: 0.9rem;
    }

    .bath-card h3 {
        font-size: 1rem;
        line-height: 1.18;
        margin-bottom: 0;
    }

    .bath-card .meta {
        gap: 0.35rem;
        margin: 0.55rem 0 0.45rem;
        font-size: 0.78rem;
    }

    .bath-tag {
        gap: 0.22rem;
        padding: 0.2rem 0.42rem;
        border-radius: 999px;
    }

    .bath-tag i {
        font-size: 0.78rem;
    }

    .indications {
        margin: 0.35rem 0;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .closed-note {
        margin: 0.35rem 0;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .bath-card .description {
        font-size: 0.8rem;
        line-height: 1.35;
        -webkit-line-clamp: 1;
    }

    .action-buttons {
        gap: 0.4rem;
        margin-top: 0.75rem;
    }

    .btn-action {
        min-height: 42px;
        padding: 0.45rem;
    }
}

@media (max-width: 480px) {
    .map-container {
        height: 24vh;
        height: 24dvh;
        flex-basis: 24dvh;
    }

    .controls {
        max-height: 44dvh;
    }

    .filter-heading {
        flex-wrap: wrap;
    }

    .filter-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: -0.2rem;
    }

    select,
    input[type="text"] {
        padding: 0.68rem 0.85rem;
        font-size: 0.9rem;
    }

    .bath-card h3 {
        font-size: 0.96rem;
    }

    .status-badge {
        padding: 0.18rem 0.48rem;
        font-size: 0.68rem;
        letter-spacing: 0.035em;
    }
}

/* NEW: Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-action {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-action:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-action i {
    font-size: 1rem;
}

/* NEW: Indications Style */
.indications {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 0.5rem 0;
    font-style: italic;
}

.closed-note {
    font-size: 0.85rem;
    color: var(--text-dark);
    margin: 0.5rem 0;
    font-weight: 600;
}

/* NEW: Status Indicators */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-open {
    background: #dcfce7;
    color: #15803d;
}

.status-closed {
    background: #fee2e2;
    color: #b91c1c;
}

.status-unknown {
    background: #e2e8f0;
    color: #475569;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* NEW: Highlighted Marker */
.highlighted-marker {
    background: #ef4444;
    border: 3px solid white;
    border-radius: 50%;
    width: 24px !important;
    height: 24px !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.4);
    animation: pulse-marker 1.5s ease-in-out infinite;
}

@keyframes pulse-marker {

    0%,
    100% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.2);
    }
}

/* NEW: Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, rgba(241, 245, 249, 0), rgba(241, 245, 249, 1));
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.scroll-indicator.hidden {
    opacity: 0;
}

@media (max-width: 768px) {
    .controls {
        padding: 0.65rem 0.9rem;
    }

    .control-group {
        margin-bottom: 0.55rem;
    }

    .control-group label {
        margin-bottom: 0.35rem;
    }

    .list-summary {
        padding: 0.55rem 1rem;
    }

    .bath-list {
        padding: 0.7rem;
        gap: 0.65rem;
    }

    .bath-card {
        border-radius: 14px;
        padding: 0.9rem;
    }

    .bath-card h3 {
        font-size: 1rem;
        line-height: 1.18;
        margin-bottom: 0;
    }

    .bath-card .meta {
        gap: 0.35rem;
        margin: 0.55rem 0 0.45rem;
        font-size: 0.78rem;
    }

    .bath-tag {
        gap: 0.22rem;
        padding: 0.2rem 0.42rem;
        border-radius: 999px;
    }

    .indications,
    .closed-note {
        margin: 0.35rem 0;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .bath-card .description {
        font-size: 0.8rem;
        line-height: 1.35;
        -webkit-line-clamp: 1;
    }

    .action-buttons {
        gap: 0.4rem;
        margin-top: 0.7rem;
    }

    .btn-action {
        min-height: 40px;
        padding: 0.42rem;
        font-size: 0.82rem;
    }
}

@media (max-width: 480px) {
    .map-container {
        height: 22vh;
        height: 22dvh;
        flex-basis: 22dvh;
    }

    .header {
        padding: 0.9rem 1rem 0.75rem;
    }

    .controls {
        max-height: 40dvh;
    }

    select,
    input[type="text"] {
        padding: 0.58rem 0.8rem;
    }

    .input-wrapper button {
        border-radius: 10px;
        padding: 0 0.85rem;
    }

    .search-wrapper button {
        flex-basis: 40px;
    }
}
