#upIconTray {
  displayX: none !important;
}
#showSideFromHeader {
  display: none !important;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.widgetHeader {
    margin-bottom: 24px;
}

.widgetHeader h1 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 8px;
}
.widgetHeader .info {
    color: #666;
    font-size: 0.9rem;
}
#widgetDetailsControls {
    position: sticky;
    top: 0;
    z-index: 10;
    overflow: visible;
}
.search-container {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
    overflow: visible;
}

.list-selector {
    min-width: 200px;
}

.list-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.list-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-wrapper {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    width: 20px;
    height: 20px;
}

.search-fields-control {
    position: relative;
    min-width: 150px;
    overflow: visible;
}

.search-fields-btn {
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-fields-btn:hover {
    border-color: #007bff;
    background: #f8f9fa;
}

.search-fields-btn.active {
    border-color: #007bff;
    background: #f0f8ff;
}

/* Responsive filters button - show icon only when parent container < 800px */
.search-container {
    container-type: inline-size;
}

@container (max-width: 799px) {
    .search-fields-control {
        min-width: auto;
        width: 48px;
    }
    
    .search-fields-btn {
        padding: 12px;
        width: 48px;
        min-width: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .search-fields-btn .button-text {
        display: none;
    }
    
    .search-fields-btn .filter-icon {
        display: block;
    }
}

@container (min-width: 800px) {
    .search-fields-btn .button-text {
        display: block;
    }
    
    .search-fields-btn .filter-icon {
        display: none;
    }
}

.search-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 280px;
    max-width: 400px;
}

.search-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.search-popup-title {
    font-weight: 600;
    color: #1a1a1a;
}

.search-popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-popup-close:hover {
    color: #333;
}

.search-popup-actions {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
}

.popup-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.popup-btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.search-fields-popup {
    position: sticky;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    margin-top: 4px;
    min-width: 280px;
    max-width: 400px;
    width: max-content;
}

.dark .search-fields-popup {
    background: #333;
    border-color: #555;
}

.search-fields-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-weight: 500;
}

.dark .search-fields-header {
    border-bottom-color: #555;
}

.select-all-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.select-all-btn:hover {
    background: #0056b3;
}

.search-fields-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.search-field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-field-item:hover {
    background: #f8f9fa;
}

.search-field-checkbox {
    margin: 0;
}

.search-field-label {
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
}

.search-results {
    font-size: 0.9rem;
    color: #666;
}

.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    position: relative;
}

.add-visit-btn {
    margin-left: 16px;
    padding: 10px 20px;
    background: #007bff;
    color: white !important;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.add-visit-btn:hover {
    background: #0056b3;
}

.pagination-info {
    font-size: 0.9rem;
    color: #666;
    margin: 0 16px;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #007bff;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

#widgetDetailsBottom {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 15px;
    border-top: 1px solid #e5e5e5;
    z-index: 10;
}

.dark #widgetDetailsBottom {
    background: #333;
    border-top-color: #555;
}

.page-numbers {
    display: flex;
    gap: 4px;
}

.loading {
    text-align: center;
    padding: 48px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    text-align: center;
    padding: 24px;
}

.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 16px;
    border-radius: 8px;
    display: inline-block;
}

.error-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.listings-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}

.listings-scroll-container {
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    min-height: 300px;
    margin-top: -20px; /* Places under control fade out */
    padding-top: 15px;
}

.listing-card {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
    padding: 24px;
    transition: box-shadow 0.2s, transform 0.2s;
}

.listing-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.listing-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.listing-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.listing-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

.listing-category {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1d4ed8;
    background: #dbeafe;
    border-radius: 16px;
    width: fit-content;
}

.listing-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

.listing-secondary {
    color: #666;
    font-size: 0.9rem;
    margin-top: 4px;
    line-height: 1.4;
}

.listing-tertiary {
    color: #666;
    font-size: 0.9rem;
    margin-top: 2px;
    line-height: 1.4;
}

.address-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.address-main {
    color: #4a4a4a;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.address-details {
    color: #666;
    font-size: 0.9rem;
}

.contact-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contact-item {
    color: #4a4a4a;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contact-item a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.contact-item a:hover {
    color: #007bff;
}

.population-item {
    color: #4a4a4a;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.additional-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e5;
}

.details-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0;
    width: 100%;
    justify-content: flex-start;
}

.details-toggle:hover {
    color: #007bff;
}
.dark .details-toggle:hover {
    color: #ddd;
}
.toggle-arrow {
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.details-content {
    margin-top: 8px;
    display: none;
    font-size: 11px;
    line-height: 1.6;
}

.details-content.expanded {
    display: block;
}

.details-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-row,
.detail-item {
    display: flex;
    font-size: 11px;
    gap: 8px;
    line-height: 1.6;
    margin-bottom: 4px;
}

.detail-item.stacked {
    flex-direction: column;
    gap: 2px;
}

.detail-key,
.detail-label {
    font-weight: 500;
    min-width: 100px;
    flex-shrink: 0;
}

.detail-label {
    font-weight: bold;
}

.detail-value {
    word-break: break-word;
    flex: 1;
}

.no-results {
    text-align: center;
    padding: 48px;
}

.no-results-text {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.clear-search {
    color: #007bff;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.clear-search:hover {
    color: #0056b3;
}

.empty-state {
    text-align: center;
    padding: 48px;
}

.empty-text {
    color: #666;
    font-size: 1.1rem;
}

.break-all {
    word-break: break-all;
}

/* Widget Top Layout */
#widgetTop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#widgetTop .search-results {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

#widgetTop .pagination-container {
    margin: 0;
}

/* Page Layout Styles */
#widgetContent {
    display: flex;
    flex-direction: row;
    min-heightX: calc(100vh - 200px); /* Account for header space */
    min-height: 400px;
    gap: 16px;
    margin-bottom: 20px;
}

#pageGallery {
    background: white;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    position: relative;
    line-height: 0px;
}

.gallery-banner {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

#widgetDetailsParent {
    min-heightX: 400px;
    heightX:100%;
    margin-bottom: 15px;
}
#widgetDetails {
    overflow: visible;
}
#pageMap {
    border-radius: 8px;
}

#pageMap #widgetmap {
    margin-bottom: 0;
    height: 100%;
}

/* Mobile Layout: ≤600px - Stack vertically */
@media (max-width: 600px) {
    #widgetContent {
        flex-direction: column;
        height: auto;
        min-height: auto;
    }

    .right-column {
        display: flex;
        flex-direction: column;

        gap: 16px;
    }

    #pageGallery {
        order: 1;
        height: 30vh;
        overflow-y: auto;
    }

    #widgetDetailsParent {
        order: 1; /* Shows first on mobile */
    }

    #pageMap {
        order: 2;
    }
}

/* Desktop Layout: >600px - Side by side with Details left, Gallery+Map right */
@media (min-width: 601px) {
    #widgetContent {
        flex-direction: row;
        heightX: calc(100vh - 200px); /* Full height minus header */
        gap: 20px;
    }

    #widgetDetailsParent {
        flex: 0 0 55%;
        order: 1;
    }

    .right-column {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 16px;
        order: 2;
    }

    #pageGalleryParent {
        height: 50%;
        overflow-y: auto;
    }

    #pageMap {
        heightX: 100%; /* Or 50% */
        display: flex;
        flex-direction: column;
    }

    #pageMap #widgetmap {
        flex: 1;
    }
}

/* Map wrapper in hero mode */
#widgetHero #widgetmapWrapper {
    width: 100% !important;
    height: 100vh !important;
}

#widgetHero #widgetmap {
    width: 100% !important;
    height: 100% !important;
}
.leaflet-container {
    background: none !important; /* Prevents white corner radius edge */
    /* outline-offset: 0px !important; Not sure if we'll need this */
}
.leaflet-container a.leaflet-popup-close-button {
    font: 18px / 24px Tahoma, Verdana, sans-serif !important; /* For map popup close-X */
}