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

:root {
    --green:       #4a9e6b;
    --green-dark:  #2e7d4f;
    --green-light: #e8f5ee;
    --orange:      #ff6b2b;
    --orange-dark: #e55a1e;
    --gray-100:    #f5f5f5;
    --gray-200:    #e8e8e8;
    --gray-400:    #b0b0b0;
    --gray-600:    #666;
    --gray-800:    #333;
    --white:       #fff;
    --shadow-sm:   0 1px 4px rgba(0,0,0,.10);
    --shadow-md:   0 4px 16px rgba(0,0,0,.14);
    --radius:      8px;
}

html, body {
    height: 100%;
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-100);
}

a { color: inherit; text-decoration: none; }

/* ── Navbar ── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    /* needed so .mobile-nav-menu positions relative to the navbar */
    isolation: isolate;
}

.navbar-inner {
    max-width: 100%;
    padding: 0 20px;
    height: 58px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 20px;
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 20px;
}

.nav-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
}

/* Inline search in navbar */
.nav-search {
    flex: 1;
    max-width: 340px;
    position: relative;
}

.nav-search input {
    width: 100%;
    padding: 7px 14px 7px 34px;
    border: 1.5px solid var(--gray-200);
    border-radius: 20px;
    font-size: 13px;
    background: var(--gray-100);
    color: var(--gray-800);
    outline: none;
    transition: border-color .15s, background .15s;
}

.nav-search input:focus {
    border-color: var(--green);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(74,158,107,.10);
}

.nav-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 13px;
    pointer-events: none;
}

/* Burger button — hidden on desktop */
.nav-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    flex-shrink: 0;
}
.nav-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--gray-600);
    border-radius: 2px;
    transition: transform .2s, opacity .2s, width .2s;
    transform-origin: center;
}
.nav-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; width: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile dropdown menu */
.mobile-nav-menu {
    display: none;
    position: absolute;
    top: 58px;
    left: 0; right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    z-index: 900;
    padding: 8px 12px 12px;
    flex-direction: column;
    gap: 2px;
    animation: mobile-menu-slide .18s ease;
}
@keyframes mobile-menu-slide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mobile-nav-menu.open { display: flex; }
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-600);
    text-decoration: none;
    transition: background .1s, color .1s;
}
.mobile-nav-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.mobile-nav-link:hover  { background: var(--gray-100); color: var(--gray-800); }
.mobile-nav-link.active { background: var(--gray-100); color: var(--gray-800); font-weight: 700; }
.mobile-nav-divider {
    height: 1px; background: var(--gray-200); margin: 6px 0;
}
.mobile-nav-lang {
    display: flex; gap: 8px; padding: 4px 14px;
}
.mobile-nav-lang a {
    font-size: 13px; font-weight: 600; color: var(--gray-400);
    text-decoration: none; padding: 6px 10px; border-radius: 8px;
    transition: background .1s, color .1s;
}
.mobile-nav-lang a.active { color: var(--gray-800); background: var(--gray-100); }

/* Hub & Spoke nav — links + Add button in one centered row */
.nav-hub {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 4px;
}

.nav-hub-link {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    white-space: nowrap;
    transition: color .12s, background .12s;
}

.nav-hub-link:hover {
    color: var(--gray-800);
    background: var(--white);
}

.nav-hub-link.active {
    color: var(--gray-800);
    font-weight: 700;
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Vertical divider in nav-right */
.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--gray-200);
    flex-shrink: 0;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
}

.lang-toggle a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-size: 15px;
    transition: background .12s;
    opacity: .4;
}

.lang-toggle a.active {
    opacity: 1;
    background: var(--gray-100);
}

.lang-toggle a:hover { opacity: .7; background: var(--gray-100); }
.lang-toggle a.active:hover { opacity: 1; }

.nav-user {
    font-size: 13px;
    color: var(--gray-700);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    transition: background .12s;
}
.nav-user:hover { background: var(--gray-100); }

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-200);
    flex-shrink: 0;
}

.nav-logout {
    font-size: 16px;
    padding: 6px 8px;
    color: var(--gray-400);
    border-radius: 6px;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
}
.nav-logout:hover { background: #fff0f0; color: #c0392b; }

/* ── Add dropdown ── */
.add-dropdown {
    position: relative;
}

.add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 34px;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(46,125,79,.35);
    transition: background .12s, box-shadow .12s, transform .1s;
    white-space: nowrap;
}

.add-btn i { font-size: 15px; }
.add-btn:hover { background: var(--green-dark); box-shadow: 0 3px 10px rgba(46,125,79,.45); }
.add-btn:active { transform: scale(.97); }

.add-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 270px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 999;
}

.add-dropdown-menu.open { display: block; }

.add-dropdown-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: var(--gray-800);
    transition: background .12s;
    border-bottom: 1px solid var(--gray-200);
}

.add-dropdown-item:last-child { border-bottom: none; }
.add-dropdown-item:hover { background: var(--gray-100); }

.add-dropdown-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.add-dropdown-label {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}

.add-dropdown-sub {
    font-size: 11px;
    color: var(--gray-400);
    line-height: 1.3;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s;
    font-family: inherit;
}

.btn:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover { background: var(--green-dark); }

/* ── Map layout ── */
.map-page {
    display: flex;
    height: calc(100vh - 58px);
    overflow: hidden;
}

/* ── Filter sidebar ── */
.filter-sidebar {
    width: 270px;
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.filter-sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 2px;
}

.filter-sidebar-sub {
    font-size: 12px;
    color: var(--gray-400);
}

.filter-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

/* Scrollbar */
.filter-sidebar-body::-webkit-scrollbar { width: 4px; }
.filter-sidebar-body::-webkit-scrollbar-track { background: transparent; }
.filter-sidebar-body::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

.filter-group {
    margin-bottom: 20px;
}

.filter-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--gray-400);
    margin-bottom: 8px;
    padding-left: 4px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
    user-select: none;
    margin-bottom: 2px;
}

.filter-item:hover { background: var(--gray-100); }
.filter-item.active { background: var(--green-light); }

.filter-item input[type="checkbox"] {
    display: none;
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-200);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
    background: var(--white);
}

.filter-item.active .filter-checkbox {
    border-color: transparent;
    background: var(--green);
}

.filter-item.active .filter-checkbox::after {
    content: '✓';
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.filter-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    flex: 1;
}

.filter-count {
    font-size: 11px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 1px 7px;
    border-radius: 10px;
}

.filter-item.active .filter-count {
    background: rgba(74,158,107,.15);
    color: var(--green-dark);
}

/* Select all / clear */
.filter-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
}

.filter-action-btn {
    flex: 1;
    padding: 7px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-600);
    transition: all .12s;
    font-family: inherit;
    text-align: center;
}

.filter-action-btn:hover {
    border-color: var(--green);
    color: var(--green-dark);
    background: var(--green-light);
}

/* ── Map container ── */
.map-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Map overlay pill (result count) */
.map-pill {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: var(--white);
    box-shadow: var(--shadow-md);
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    pointer-events: none;
    white-space: nowrap;
}

.map-pill span { color: var(--green); }

/* Map popup custom style */
.rr-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 0;
    overflow: hidden;
}

.rr-popup .leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.popup-inner {
    padding: 14px 16px;
}

.popup-type {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.popup-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.popup-desc {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 10px;
    line-height: 1.4;
}

.popup-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 10px;
}

.popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 0 14px 12px;
    padding: 8px 14px;
    background: var(--green);
    color: #fff !important;
    text-align: center;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background .12s;
    border: none;
    font-family: inherit;
    text-decoration: none !important;
    letter-spacing: .2px;
}

.popup-btn:hover { background: var(--green-dark); color: #fff !important; }

/* ── Leaflet overrides ── */
.leaflet-control-attribution { font-size: 10px !important; }
.leaflet-control-zoom a {
    border-radius: 6px !important;
    font-size: 16px !important;
}

/* ── Mobile filter button ── */
.filter-fab {
    display: none;
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: 24px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    display: none;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* ── Bottom sheet ── */
.filter-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 900;
}

.filter-sheet-overlay.open { display: block; }

.filter-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 901;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
}

.filter-sheet.open { transform: translateY(0); }

.filter-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

.filter-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.filter-sheet-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.filter-sheet-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-100);
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
}

.filter-sheet-search {
    position: relative;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.filter-sheet-search input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border: 1.5px solid var(--gray-200);
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    background: var(--gray-100);
    outline: none;
    transition: border-color .15s;
}

.filter-sheet-search input:focus { border-color: var(--green); background: var(--white); }

.filter-sheet-search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 13px;
    pointer-events: none;
}

.filter-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
}

.filter-sheet-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ── Responsive ── */
@media (max-width: 860px) {
    .nav-hub-link { display: none; }
    .nav-search { display: none; }
    .nav-burger { display: flex; }

    .navbar-inner { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; }
    .nav-left  { display: contents; }
    .nav-right { padding-left: 0; justify-content: flex-end; }
    .lang-toggle { display: none; }
    .nav-divider { display: none; }
    .nav-user-name { display: none; }
    .nav-user { padding: 3px; border-radius: 50%; }
    .nav-logout { display: none; }
    /* Hub pill loses its background when links are hidden */
    .nav-hub { background: transparent; border: none; padding: 0; gap: 0; }

    /* Hide desktop sidebar */
    .filter-sidebar { display: none; }

    /* Show FAB */
    .filter-fab { display: flex; }

    /* Map fills full width */
    .map-page { display: block; height: calc(100vh - 58px); position: relative; }
    .map-wrap { height: 100%; }
}
