/* Our Communities Page */

/* Breadcrumb */
.communities-breadcrumb {
    font-size: 0.8rem;
    padding-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-medium, #6b7280);
}
.communities-breadcrumb a {
    color: var(--text-medium, #6b7280);
    transition: var(--transition);
}
.communities-breadcrumb a:hover {
    color: var(--primary-color);
}
.communities-breadcrumb .separator {
    margin: 0 0.35rem;
    color: var(--text-light, #9ca3af);
}
.communities-breadcrumb span:last-child {
    font-weight: 600;
    color: var(--text-darkest, #111827);
}

/* Header Row */
.communities-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 500;
}
.communities-title {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 800;
    color: var(--text-darkest, #0d1b2a);
    letter-spacing: -0.02em;
}
.communities-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== Location Dropdown ===== */
.location-wrap {
    position: relative;
}
.location-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--border-color, #e4e7ec);
    border-radius: 8px;
    background: white;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-darkest, #111827);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}
.location-toggle:hover {
    border-color: var(--primary-color);
}
.loc-arrow {
    font-size: 0.65rem;
    color: var(--text-medium);
    transition: transform 0.2s ease;
}
.location-wrap.open .loc-arrow {
    transform: rotate(180deg);
}
.location-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 280px;
    background: white;
    border: 1px solid var(--border-color, #e4e7ec);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 200;
}
.location-wrap.open .location-dropdown {
    display: block;
}

/* Search field */
.loc-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.7rem 0.7rem 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color, #e4e7ec);
    border-radius: 8px;
    background: white;
}
.loc-search input {
    border: none;
    outline: none;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-darkest);
    width: 100%;
    background: transparent;
    order: -1;
}
.loc-search input::placeholder {
    color: var(--text-light, #9ca3af);
}
.loc-search i {
    font-size: 0.8rem;
    color: var(--text-light, #9ca3af);
    flex-shrink: 0;
}

/* Options list */
.loc-options {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.loc-options::-webkit-scrollbar {
    width: 5px;
}
.loc-options::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Custom checkbox styling */
.loc-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
    color: var(--text-darkest, #111827);
    cursor: pointer;
    transition: background 0.15s ease;
}
.loc-option:hover {
    background: var(--bg-light, #f7f8fa);
}
.loc-option input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all 0.15s ease;
}
.loc-option input[type="checkbox"]:checked {
    background: var(--primary-color, #FEA327);
    border-color: var(--primary-color, #FEA327);
}
.loc-option input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.loc-option input[type="checkbox"]:indeterminate {
    background: var(--primary-color, #FEA327);
    border-color: var(--primary-color, #FEA327);
}
.loc-option input[type="checkbox"]:indeterminate::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 3px;
    width: 8px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

/* Select All */
.loc-select-all {
    font-weight: 600;
    border-bottom: 1px solid var(--border-color, #e4e7ec);
    padding-bottom: 0.55rem;
    margin-bottom: 0.15rem;
}

/* State group */
.loc-state-group {
    margin-top: 0.15rem;
}
.loc-state-row {
    padding-top: 0.55rem;
    padding-bottom: 0.35rem;
}
.loc-state-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-darkest, #111827);
}

/* Community row */
.loc-community {
    padding-left: 1.6rem;
}
.loc-community-name {
    font-weight: 500;
}

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    border: 1.5px solid var(--border-color, #e4e7ec);
    border-radius: 8px;
    overflow: hidden;
}
.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 36px;
    border: none;
    background: white;
    color: var(--text-medium, #6b7280);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}
.view-btn:first-child {
    border-right: 1.5px solid var(--border-color, #e4e7ec);
}
.view-btn:hover {
    background: var(--bg-light, #f7f8fa);
}
.view-btn.active {
    background: var(--primary-color, #FEA327);
    color: white;
}

/* ===== Main Layout ===== */
.communities-layout {
    display: flex;
    height: calc(100vh - 215px);
    min-height: 480px;
    border: 1px solid var(--border-color, #e4e7ec);
    border-radius: var(--border-radius-lg, 16px);
    overflow: hidden;
    margin-bottom: 3rem;
}

/* Sidebar */
.communities-sidebar {
    width: 340px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border-color, #e4e7ec);
    background: white;
}
.communities-sidebar::-webkit-scrollbar {
    width: 5px;
}
.communities-sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* Grid-only mode */
.communities-layout.grid-only {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
}
.communities-layout.grid-only .communities-map {
    display: none;
}
.communities-layout.grid-only .communities-sidebar {
    width: 100%;
    max-height: none;
    overflow: visible;
    border-right: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
}
.communities-layout.grid-only .comm-card {
    flex-direction: column;
    gap: 0;
    padding: 0;
    border-bottom: none;
    border-radius: 14px;
    overflow: hidden;
    background: white;
    border: 1px solid var(--border-color, #e4e7ec);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.communities-layout.grid-only .comm-card:hover {
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}
.communities-layout.grid-only .comm-card-thumb {
    width: 100%;
    height: 200px;
    border-radius: 14px 14px 0 0;
}
.communities-layout.grid-only .comm-card-overlays {
    display: flex;
}
.communities-layout.grid-only .comm-share-btn {
    display: flex;
}
.communities-layout.grid-only .comm-card-info {
    padding: 0.85rem 1rem 1rem;
}
.communities-layout.grid-only .comm-card-name {
    font-size: 1rem;
}
.communities-layout.grid-only .comm-card-loc {
    display: none;
}
.communities-layout.grid-only .comm-empty {
    grid-column: 1 / -1;
}

/* ===== Sidebar Card ===== */
.comm-card {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-color, #e4e7ec);
}
.comm-card:last-child {
    border-bottom: none;
}
.comm-card:hover {
    background: var(--bg-light, #f7f8fa);
}
.comm-card.active {
    background: rgba(254, 163, 39, 0.06);
}
.comm-card.hidden {
    display: none;
}
.comm-card-thumb {
    position: relative;
    width: 140px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
}
.comm-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Card overlays (badges + share) — hidden in list view, shown in grid view */
.comm-card-overlays {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    align-items: center;
    gap: 0.4rem;
    z-index: 2;
}
.comm-badge-state {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    line-height: 1;
    backdrop-filter: blur(4px);
}
.comm-badge-state i {
    font-size: 0.6rem;
}
.comm-badge-top {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    line-height: 1;
    z-index: 2;
}
/* In grid mode, badge-top repositions into overlay row */
.communities-layout.grid-only .comm-badge-top {
    position: static;
}
.communities-layout.grid-only .comm-card-overlays {
    top: 10px;
    left: 10px;
}
.comm-share-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.72rem;
    z-index: 2;
    transition: background 0.15s ease;
    backdrop-filter: blur(4px);
}
.comm-share-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}
.comm-card-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.comm-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-darkest, #0d1b2a);
    line-height: 1.3;
    margin-bottom: 0.3rem;
}
.comm-card-loc {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-medium, #6b7280);
    font-weight: 500;
}
.loc-pin-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color, #FEA327);
    flex-shrink: 0;
}
.comm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.75rem;
    color: var(--text-light, #94a0b0);
    font-size: 0.95rem;
}
.comm-empty i {
    font-size: 2rem;
}

/* ===== Map ===== */
.communities-map {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Custom expand button on map */
.map-expand-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: background 0.15s ease;
}
.map-expand-btn:hover {
    background: #f4f4f4;
}

/* Gold marker cluster overrides */
.marker-cluster-small {
    background-color: rgba(254, 163, 39, 0.35) !important;
}
.marker-cluster-small div {
    background-color: rgba(254, 163, 39, 0.9) !important;
    color: white !important;
    font-weight: 700;
}
.marker-cluster-medium {
    background-color: rgba(254, 163, 39, 0.35) !important;
}
.marker-cluster-medium div {
    background-color: rgba(254, 163, 39, 0.85) !important;
    color: white !important;
    font-weight: 700;
}
.marker-cluster-large {
    background-color: rgba(254, 163, 39, 0.35) !important;
}
.marker-cluster-large div {
    background-color: rgba(254, 163, 39, 0.8) !important;
    color: white !important;
    font-weight: 700;
}

/* Map popup */
.map-popup-content {
    font-family: 'Inter', sans-serif;
    min-width: 200px;
}
.map-popup-content .popup-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: block;
}
.map-popup-content h4 {
    font-size: 0.92rem;
    font-weight: 700;
    color: #0d1b2a;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}
.map-popup-content p {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.15rem;
}
.map-popup-content .popup-units {
    font-size: 0.78rem;
    color: #22c55e;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.map-popup-content .popup-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary-color, #FEA327);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s ease;
}
.map-popup-content .popup-link:hover {
    background: var(--primary-hover, #e59420);
    color: #fff;
}

/* ===== Fullscreen mode ===== */
.communities-layout.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    border: none;
    margin: 0;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .communities-layout {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }
    .communities-sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .communities-map {
        height: 400px;
    }
    .communities-layout.grid-only .communities-sidebar {
        grid-template-columns: repeat(2, 1fr);
        max-height: none;
    }
}
@media (max-width: 600px) {
    .communities-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .communities-controls {
        width: 100%;
        justify-content: space-between;
    }
    .comm-card-thumb {
        width: 110px;
        height: 80px;
    }
    .communities-map {
        height: 320px;
    }
    .communities-layout.grid-only .communities-sidebar {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }
}
