@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");
html, body { height: 100%; margin: 0; padding: 0; font-family: 'Prompt', sans-serif; }

/* Fix z-index for Bootstrap modals to be above all other elements */
.modal {
    z-index: 9999 !important;
}
.modal-backdrop {
    z-index: 9998 !important;
}

/* Lower z-index when sidebar is open */
.navbar {
    transition: z-index 0s;
}

body:has(.sidebar-container.visible) .navbar {
    z-index: 500 !important;
}

/* ========================================
   Global Border Radius for Inputs & Buttons
   ======================================== */
/* All text inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="file"],
textarea,
.form-control,
.form-select,
select {
    border-radius: 50px !important;
}

/* All buttons */
button,
.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info,
.btn-light,
.btn-dark,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-light,
.btn-outline-dark,
.btn-sm,
.btn-lg,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    border-radius: 50px !important;
}

/* Search inputs - specific */
#searchInput,
#searchPopupInput {
    border-radius: 50px !important;
}

/* Form Validation - Required Field Highlight */
.form-control.is-invalid,
.form-select.is-invalid {
    border: 3px solid #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

/* SweetAlert2 Customization */
.swal2-popup {
    font-family: 'Prompt', sans-serif !important;
}
.swal2-title {
    font-family: 'Prompt', sans-serif !important;
    font-weight: 600;
}
.swal2-html-container {
    font-family: 'Prompt', sans-serif !important;
}
.swal2-confirm,
.swal2-cancel {
    font-family: 'Prompt', sans-serif !important;
    font-weight: 500;
}

/* Quill Editor Customization */
#detailEditor {
    min-height: 200px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: white;
}
.ql-toolbar.ql-snow {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    font-family: 'Prompt', sans-serif;
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
.ql-container.ql-snow {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    background-color: white;
    border-color: #dee2e6;
}
.ql-editor {
    min-height: 150px;
    background-color: white;
}
.ql-editor.ql-blank::before {
    font-style: normal;
    color: #999;
}

.sidebar-container {
    position: fixed;
    top: 60px;
    right: 0;
    width: 380px;
    height: calc(100% - 60px);
    background-color: #f8f9fa;
    box-shadow: -2px 0 12px rgba(0,0,0,0.1);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out, z-index 0s;
    box-sizing: border-box;
    padding: 24px;
    overflow-y: auto;
}
.sidebar-container.visible {
    transform: translateX(0);
    z-index: 9999; /* Higher than all other elements when visible */
}
.sidebar-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
    color: #212529;
    font-size: 20px;
}

/* Form Section Headers */
.sidebar-container h5 {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin-top: 24px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #dee2e6;
}

.sidebar-container h5:first-of-type {
    margin-top: 0;
}

/* Hidden fields should not have form-group styling */
.sidebar-container input[type="hidden"] {
    padding: 0;
    margin: 0;
    border: none;
}

/* Form Groups with subtle background */
.sidebar-container .mb-3 {
    background-color: white;
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s ease;
}

.sidebar-container .mb-3:hover {
    border-color: #dee2e6;
}

/* Shop Panel - special styling for conditional section */
#shopPanel {
    background-color: #fff9e6;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #ffe69c;
    margin-top: 12px;
    margin-bottom: 16px;
}

#shopPanel .mb-3 {
    background-color: white;
}

.sidebar-container label {
    display: block;
    margin-bottom: 6px;
    margin-top: 0;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

/* Remove extra padding from label inside form groups */
.sidebar-container .mb-3 label.form-label {
    margin-bottom: 8px;
}

/* Input fields styling */
.sidebar-container input[type="text"],
.sidebar-container input[type="number"],
.sidebar-container input[type="file"],
.sidebar-container textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Prompt', sans-serif;
    background-color: white;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.sidebar-container input[type="text"]:focus,
.sidebar-container input[type="number"]:focus,
.sidebar-container input[type="file"]:focus,
.sidebar-container textarea:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Radio buttons container */
.sidebar-container .form-check-inline {
    margin-right: 16px;
}

/* Small text / form hints */
.sidebar-container .form-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* Object type radio container */
#objectTypeContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#objectTypeContainer .form-check {
    padding-left: 0;
}

#objectTypeContainer .form-check-input {
    margin-right: 8px;
}

.sidebar-container select,
.sidebar-container select option {
    color: #212529;
    background-color: white;
}
.sidebar-container select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Prompt', sans-serif;
}
.sidebar-container select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
.sidebar-buttons {
    text-align: right;
    position: sticky;
    bottom: 0;
    margin-top: 20px;
    display: flex;
    gap: 10px;
    background: #f8f9fa;
    padding: 16px 0 20px 0;
    border-top: 2px solid #dee2e6;
    z-index: 1002;
}
.sidebar-buttons button {
    flex: 1;
}
.map-label-overlay {
    color: #FFFF00;
    background-color: rgba(0, 0, 0, 0.7);
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    /* position: absolute; removed - AME handles positioning */
    white-space: nowrap;
    pointer-events: auto; /* Allow clicks on labels */
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.map-category-label {
    /* position: absolute; removed - AME handles positioning */
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer;
    background-color: #654321;
    color: #FFD700;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 10px;
    border: 2px solid #8B4513;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    margin-bottom: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.map-category-label:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 6px rgba(0,0,0,0.5);
}
.village-hover-label {
    position: absolute;
    white-space: nowrap;
    pointer-events: none;
    color: #999;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* Village name marker labels with white border */
div[style*="position: absolute"][style*="user-select: none"] > div > div {
    -webkit-text-stroke: 6px white;
    text-stroke: 6px white;
    paint-order: stroke fill;
}
.info-loader-container { display: flex; align-items: center; gap: 10px; }
.info-loader { border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 25px; height: 25px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.info-window-content { min-width: 200px; max-width: 200px; font-family: 'Prompt', sans-serif; }
.info-window-actions { position: absolute; top: 10px; left: 10px; display: flex; gap: 5px; z-index: 2; }
.info-action-icon { cursor: pointer; font-size: 18px; opacity: 0.7; transition: opacity 0.2s; }
.info-action-icon:hover { opacity: 1; }
.info-window-body h3 { margin-top: 0; margin-left: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.7em; }
.info-window-thumbnail { width: 100%; max-width: 120px; height: auto; margin: 10px 0; border-radius: 4px; }
.file-preview-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
}
.file-preview-item {
    display: flex;
    gap: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px;
    background: white;
}
.file-preview-thumbnail {
    position: relative;
    min-width: 80px;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

/* Larger thumbnails for lg screens and up */
@media (min-width: 992px) {
    .file-preview-thumbnail {
        min-width: 200px;
        width: 200px;
        height: 200px;
    }
}
.file-preview-thumbnail img,
.file-preview-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.file-preview-remove:hover {
    background: rgba(220, 53, 69, 1);
}
.file-preview-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.file-preview-details label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    color: #495057;
}
.file-preview-details input,
.file-preview-details select {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}
.file-preview-details input:focus,
.file-preview-details select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
.file-tag-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.file-tag-button {
    padding: 4px 12px;
    font-size: 11px;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.file-tag-button:hover {
    border-color: #80bdff;
    background: #e7f3ff;
    color: #0056b3;
}
.file-tag-button.selected {
    background: #007bff;
    color: white;
    border-color: #007bff;
}
.file-tag-button.selected:hover {
    background: #0056b3;
    border-color: #0056b3;
}
.info-window-footer { margin-top: 10px; text-align: center; display: flex; gap: 8px; justify-content: center; }
.info-window-footer button {
    background: transparent;
    color: #2196F3;
    border: 2px solid #2196F3;
    padding: 8px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-window-footer button:hover {
    background-color: #2196F3;
    color: white;
}
.info-window-footer button.btn-navigation {
    color: #4CAF50;
    border-color: #4CAF50;
}
.info-window-footer button.btn-navigation:hover {
    background-color: #4CAF50;
    color: white;
}

/* Hide button text on xs and sm screens, show only icons */
@media (max-width: 767px) {
    .info-window-footer button {
        padding: 8px 12px;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
        gap: 0;
    }
    .info-window-footer button .btn-text {
        display: none;
    }
    .info-window-footer button i {
        margin: 0;
        font-size: 16px;
    }
}
.info-window-thumbnail { cursor: pointer; }

/* InfoWindow Custom Styles */
.gm-style .gm-style-iw-c {
    padding: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    max-width: 180px !important;
    z-index: 99999 !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    max-width: 180px !important;
}

.gm-style .gm-style-iw-t {
    z-index: 99999 !important;
}

.gm-style .gm-style-iw-t::after {
    background: white !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    z-index: 99999 !important;
}

.gm-style-iw {
    z-index: 99999 !important;
}

.gm-style-iw-tc {
    z-index: 99999 !important;
}

/* Force InfoWindow to be on top of everything */
.gm-style div[aria-live="polite"] {
    z-index: 99999 !important;
}

/* Close Button - Float Right */
.gm-ui-hover-effect {
    top: 6px !important;
    right: 6px !important;
    width: 32px !important;
    height: 32px !important;
    opacity: 0.9 !important;
}

.gm-ui-hover-effect:hover {
    opacity: 1 !important;
}

.gm-ui-hover-effect > span {
    background-color: #333 !important;
    width: 18px !important;
    height: 18px !important;
    margin: 7px !important;
}

/* InfoWindow Container */
.iw-container {
    font-family: 'Prompt', sans-serif;
    position: relative;
    width: 180px;
    background: white;
    overflow: hidden;
}

/* Loading State */
.info-loading {
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.spinner {
    border: 2px solid #f0f0f0;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Image Container */
.iw-image-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iw-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.4s ease;
}

.iw-image:hover {
    transform: scale(1.05);
}

/* Action Buttons - Centered */
.iw-actions-center {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px 0 12px;
}

.iw-action-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.98);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.iw-action-btn:hover {
    background: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.iw-action-btn:active {
    transform: scale(1.05);
}

/* Body */
.iw-body {
    padding: 12px;
}

.iw-title {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.iw-subtitle {
    margin: 0;
    font-size: 11px;
    color: #757575;
    line-height: 1.5;
}

/* Footer */
.iw-footer {
    display: flex;
    gap: 6px;
    padding: 0 12px 12px 12px;
}

.iw-btn {
    flex: 1;
    background: white;
    border: 1.5px solid #e0e0e0;
    color: #424242;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    font-family: 'Prompt', sans-serif;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.iw-btn:hover {
    background-color: #f5f5f5;
    border-color: #bdbdbd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.iw-btn:active {
    transform: translateY(0);
}

.iw-btn-detail {
    color: #2196F3;
    border-color: #2196F3;
    background: rgba(33, 150, 243, 0.04);
}

.iw-btn-detail:hover {
    background: rgba(33, 150, 243, 0.1);
    border-color: #2196F3;
}

.iw-btn-nav {
    color: #4CAF50;
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.04);
}

.iw-btn-nav:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4CAF50;
}

.iw-btn i {
    font-size: 12px;
}

.detail-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    backdrop-filter: blur(4px);
}
.detail-popup-content {
    background: white;
    margin: 50px auto !important;
    max-width: 700px;
    max-height: calc(100vh - 100px);
    height: auto;
    border-radius: 12px;
    padding: 0;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    width: 90%;
}
.detail-popup-content::-webkit-scrollbar {
    width: 8px;
}
.detail-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 12px 12px 0;
}
.detail-popup-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}
.detail-popup-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.detail-popup-header {
    padding: 24px;
    border-bottom: 1px solid #dee2e6;
}
.detail-popup-body {
    padding: 24px;
    overflow-x: hidden;
}
.detail-popup-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 32px;
    font-weight: 300;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.detail-popup-close:hover { color: #212529; }
.detail-popup-title {
    margin: 0;
    padding-right: 40px;
    font-weight: 600;
    color: #212529;
}
.detail-popup-section {
    margin-top: 24px;
}
.detail-popup-section h4 {
    margin-bottom: 12px;
    font-weight: 600;
    color: #495057;
    font-size: 16px;
}

/* Detail Section Styles */
.detail-section {
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    margin: 0 0 16px 0;
    font-weight: 600;
    color: #495057;
    font-size: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #dee2e6;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.detail-info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: box-shadow 0.2s ease;
}

.detail-info-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.detail-label {
    font-weight: 500;
    color: #6c757d;
    font-size: 14px;
    flex-shrink: 0;
    margin-right: 12px;
}

.detail-value {
    font-weight: 400;
    color: #212529;
    font-size: 14px;
    text-align: right;
    word-break: break-word;
}

.detail-value i.bi {
    font-size: 16px;
}

/* Success/Error colors for status icons */
.detail-value .text-success {
    color: #28a745 !important;
}

.detail-value .text-danger {
    color: #dc3545 !important;
}
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.media-gallery-item {
    width: 100%;
    height: 160px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}
.media-gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1;
}
.media-gallery-item img, .media-gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-width: 100%;
    transition: transform 0.3s ease;
}
.media-gallery-item:hover img,
.media-gallery-item:hover video {
    transform: scale(1.1);
}

/* Photo tag group styles */
.photo-tag-group {
    margin-bottom: 24px;
}
.photo-tag-title {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 12px 0;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    border-radius: 4px;
}

/* ป้องกันรูปภาพล้น container */
.detail-popup-body img {
    max-width: 100%;
    height: auto;
}

/* Quill indent styles for popup detail */
.detail-popup-body .ql-indent-1 { padding-left: 3em; }
.detail-popup-body .ql-indent-2 { padding-left: 6em; }
.detail-popup-body .ql-indent-3 { padding-left: 9em; }
.detail-popup-body .ql-indent-4 { padding-left: 12em; }
.detail-popup-body .ql-indent-5 { padding-left: 15em; }
.detail-popup-body .ql-indent-6 { padding-left: 18em; }
.detail-popup-body .ql-indent-7 { padding-left: 21em; }
.detail-popup-body .ql-indent-8 { padding-left: 24em; }

/* Quill alignment styles for popup detail */
.detail-popup-body .ql-align-center { text-align: center; }
.detail-popup-body .ql-align-right { text-align: right; }
.detail-popup-body .ql-align-justify { text-align: justify; }

/* Quill text formatting styles for popup detail */
.detail-popup-body strong { font-weight: bold; }
.detail-popup-body em { font-style: italic; }
.detail-popup-body u { text-decoration: underline; }

/* Quill list styles for popup detail */
.detail-popup-body ol,
.detail-popup-body ul {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

/* Bullet list - Quill uses ol with data-list="bullet" */
.detail-popup-body ol[data-list="bullet"],
.detail-popup-body li[data-list="bullet"] {
    list-style-type: disc;
}

/* Ordered/Numbered list - Quill uses ol with data-list="ordered" */
.detail-popup-body ol[data-list="ordered"],
.detail-popup-body li[data-list="ordered"] {
    list-style-type: decimal;
}

/* Regular ol and ul (fallback) */
.detail-popup-body ol:not([data-list]) {
    list-style-type: decimal;
}
.detail-popup-body ul:not([data-list]) {
    list-style-type: disc;
}

.detail-popup-body li {
    margin: 0.25em 0;
}

/* Nested bullet lists */
.detail-popup-body li[data-list="bullet"] li[data-list="bullet"] {
    list-style-type: circle;
}
.detail-popup-body li[data-list="bullet"] li[data-list="bullet"] li[data-list="bullet"] {
    list-style-type: square;
}

/* Quill checklist styles */
.detail-popup-body li[data-list="checked"],
.detail-popup-body li[data-list="unchecked"] {
    list-style-type: none;
    position: relative;
    padding-left: 1.5em;
}
.detail-popup-body li[data-list="checked"]::before,
.detail-popup-body li[data-list="unchecked"]::before {
    content: '☐';
    position: absolute;
    left: 0;
    font-size: 1.1em;
}
.detail-popup-body li[data-list="checked"]::before {
    content: '☑';
    color: #28a745;
}

/* Quill header styles */
.detail-popup-body h1 { font-size: 2em; font-weight: bold; margin: 0.67em 0; }
.detail-popup-body h2 { font-size: 1.5em; font-weight: bold; margin: 0.75em 0; }
.detail-popup-body h3 { font-size: 1.17em; font-weight: bold; margin: 0.83em 0; }
.detail-popup-body h4 { font-size: 1em; font-weight: bold; margin: 1em 0; }
.detail-popup-body h5 { font-size: 0.83em; font-weight: bold; margin: 1.17em 0; }
.detail-popup-body h6 { font-size: 0.67em; font-weight: bold; margin: 1.33em 0; }

/* Quill blockquote and code-block styles */
.detail-popup-body blockquote {
    border-left: 4px solid #ccc;
    margin: 1em 0;
    padding-left: 1em;
    color: #666;
}
.detail-popup-body pre {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
}
.detail-popup-body code {
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
}

/* Quill link styles */
.detail-popup-body a {
    color: #007bff;
    text-decoration: underline;
}
.detail-popup-body a:hover {
    color: #0056b3;
}

/* Quill image and video styles */
.detail-popup-body img,
.detail-popup-body video {
    max-width: 100%;
    height: auto;
    margin: 0.5em 0;
}

/* Photo Viewer */
.photo-viewer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.95) !important;
    z-index: 30000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-viewer-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    width: 100%;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30000;
    padding: 0 10px;
}
.photo-viewer-content img {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
.photo-viewer-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 30001;
    transition: color 0.2s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-viewer-close:hover {
    color: #ddd;
}
.photo-viewer-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    z-index: 30001;
    max-width: 80%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.photo-viewer-tag {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-block;
    color: white;
    background: rgba(0, 123, 255, 0.85);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 30001;
}
.photo-viewer-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 500;
    z-index: 30001;
}
.photo-viewer-metadata {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
    z-index: 30001;
}
.photo-viewer-caption {
    color: white;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 100%;
    word-wrap: break-word;
}
.photo-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 30001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}
.photo-viewer-prev {
    left: 30px;
}
.photo-viewer-next {
    right: 30px;
}

/* Navbar - Using Bootstrap 5 classes */

/* Search Sidebar */
.search-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 350px;
    height: calc(100% - 60px);
    background: white;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    z-index: 1500;
    overflow-y: auto;
    display: none;
}
.search-sidebar.visible { display: block; }
.search-results-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.search-user-filter {
    position: sticky;
    top: 51px;
    z-index: 10;
    padding: 10px 15px;
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}
.search-user-filter .form-check-inline {
    margin-right: 15px;
}
.search-user-filter .form-check-label {
    font-weight: normal;
    cursor: pointer;
}
.search-sidebar-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    color: #6c757d;
    transition: color 0.2s;
}
.search-sidebar-close:hover {
    color: #dc3545;
}
.search-card {
    border-bottom: 1px solid #e9ecef;
    padding: 15px;
    transition: background 0.2s;
}
.search-card:hover { background: #f8f9fa; }
.search-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #212529;
}
.search-card-detail {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 10px;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}
.search-card-meta {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.search-card-meta i {
    font-size: 13px;
    color: #999;
}
.highlight {
    background-color: yellow;
    font-weight: bold;
    padding: 0 2px;
}
.search-card-thumbnail {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}
.search-card-thumbnail-placeholder {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
}
.search-card-thumbnail-clickable {
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}
.search-card-thumbnail-clickable:hover {
    opacity: 0.85;
    transform: scale(1.02);
}
.search-loading {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

/* POI Filter Container */
.poi-filter-container {
    position: fixed;
    top: 70px;
    left: 10px;
    z-index: 1600; /* Higher than search sidebar to prevent overlap */
    background: transparent;
    border-radius: 8px;
    box-shadow: none;
    padding: 12px;
    max-width: calc(100% - 370px);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    transition: left 0.3s ease-in-out, z-index 0s;
    pointer-events: none;
}

/* Lower z-index when sidebar is open */
.sidebar-container.visible ~ .poi-filter-container,
body:has(.sidebar-container.visible) .poi-filter-container {
    z-index: 500 !important;
}

.poi-filter-container * {
    pointer-events: auto;
}

/* Adjust layout order */
.filter-icon-button {
    order: 1;
}
.search-input-wrapper {
    order: 2;
}
.filter-tags-container {
    order: 3;
}

/* ขยับ filter panel ไปทางขวาเมื่อ sidebar เปิด */
.poi-filter-container.sidebar-open {
    left: 370px;
}

/* ปรับความกว้าง filter tags เมื่อ sidebar เปิด */
.poi-filter-container.sidebar-open .filter-tags-container {
    max-width: calc(100vw - 800px);
}
.poi-filter-dropdown {
    position: absolute;
    top: 50px;
    left: 0;
    min-width: 280px;
    max-width: 90vw;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 50;
    display: none;
    padding: 8px;
}
.poi-filter-dropdown.show {
    display: block;
}

/* ปรับ Choices.js ให้แสดงแบบ one line */
.poi-filter-dropdown .choices__inner {
    min-height: 38px;
    padding: 4px 8px;
}

/* ซ่อนรายการที่เลือกใน dropdown (แสดงที่ filter tags แทน) */
.poi-filter-dropdown .choices__list--multiple {
    display: none !important;
}

.poi-filter-dropdown .choices__list--multiple .choices__item {
    display: none !important;
}

/* แสดง input placeholder แทนรายการที่เลือก */
.poi-filter-dropdown .choices__input--cloned {
    display: inline-block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* แสดง placeholder เมื่อมีรายการเลือกแล้ว */
.poi-filter-dropdown .choices[data-type*="select-multiple"] .choices__inner {
    padding: 8px 10px;
    display: flex;
    align-items: center;
}

/* Custom placeholder text */
.poi-filter-dropdown .choices__input {
    background-color: transparent;
    font-size: 14px;
    padding: 0 !important;
    margin: 0 !important;
}

/* ปรับ input field ให้เต็มความกว้าง */
.poi-filter-dropdown .choices__input--cloned {
    flex: 1;
    min-width: 0;
}

/* Custom label สำหรับแสดงจำนวนที่เลือก */
.poi-filter-dropdown .custom-filter-label {
    color: #495057;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Style ปุ่ม dropdown */
.poi-filter-dropdown .choices__inner {
    border: 1px solid #ced4da;
    border-radius: 6px;
    background-color: #fff;
    cursor: pointer;
}

.poi-filter-dropdown .choices__inner:hover {
    border-color: #0d6efd;
}

/* Icon dropdown arrow */
.poi-filter-dropdown .choices[data-type*="select-multiple"]::after {
    border-color: #495057 transparent transparent;
}

/* Dropdown list style */
.poi-filter-dropdown .choices__list--dropdown {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Checkbox style สำหรับรายการที่เลือก */
.poi-filter-dropdown .choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: #f8f9fa;
}

.poi-filter-dropdown .choices__list--dropdown .choices__item[data-choice-selectable]::before {
    content: '☐ ';
    margin-right: 6px;
    font-size: 16px;
}

.poi-filter-dropdown .choices__list--dropdown .choices__item--selected::before {
    content: '☑ ';
    color: #0d6efd;
}
.filter-tags-container {
    display: none;  /* ซ่อนโดย default */
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: calc(100vw - 450px);
    padding: 2px 0;
    background-color: rgba(0, 0, 0, 0);
    border-radius: 8px;
    padding: 8px;
    pointer-events: none;
    flex-shrink: 1;
    min-width: 0;
}
.filter-tags-container:not(:empty) {
    display: flex;  /* แสดงเฉพาะเมื่อมี content */
}
.filter-tags-container * {
    pointer-events: auto;
}
.filter-tags-container::-webkit-scrollbar {
    height: 6px;
}
.filter-tags-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
.filter-tags-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}
.filter-tags-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0d6efd;
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    border: 1px solid white;
    font-size: 13px;
    white-space: nowrap;
    font-weight: 500;
}
.filter-tag-remove {
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.filter-tag-remove:hover {
    opacity: 1;
}

/* Filter Icon Button (for mobile) */
.filter-icon-button {
    display: flex !important; /* แสดงในทุก screen size */
    align-items: center;
    justify-content: center;
    position: relative;
    background: white;
    color: #0d6efd;
    border: 2px solid white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s;
    flex-shrink: 0;
}
.filter-icon-button:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}
.filter-icon-button:active {
    transform: scale(0.95);
}

/* Map Search Input */
.map-search-input {
    width: 100%;
    max-width: 65vw;
    padding: 10px 40px 10px 16px; /* เพิ่ม padding ขวาสำหรับปุ่ม close */
    border: 2px solid white;
    border-radius: 50px !important;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    background: white;
    transition: all 0.3s ease;
    display: block; /* แสดงเสมอเมื่ออยู่ใน wrapper ที่ show */
}
.map-search-input:focus {
    outline: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    border-color: #0d6efd;
}

/* Search input container with close button */
.search-input-wrapper {
    position: relative;
    display: none;
    order: 2;
    flex: 1;
    max-width: 65vw;
    z-index: 1600; /* Higher than search sidebar (1500) */
    transition: z-index 0s;
}

/* Lower z-index when sidebar is open */
body:has(.sidebar-container.visible) .search-input-wrapper {
    z-index: 500 !important;
}
.search-input-wrapper.show {
    display: flex;
    align-items: center;
}
.search-close-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    z-index: 10;
}
.search-close-btn:hover {
    color: #dc3545;
}

/* Hide navbar search input on small/medium screens only, show on lg+ */
#searchInputContainer {
    display: none !important;
}

/* Show search input on lg and up (≥992px) */
@media (min-width: 992px) {
    #searchInputContainer {
        display: block !important;
    }
}
.filter-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    border: 2px solid white;
}

/* My Location Button */
.my-location-button {
    position: fixed;
    bottom: 20px;
    left: 10px;
    background: white;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.2s;
}
.my-location-button:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}
.my-location-button:active {
    transform: scale(0.95);
}
.my-location-button i {
    color: #666;
    font-size: 20px;
}
.my-location-button.active i {
    color: #4285f4;
}

/* Map View Controls (Rotation & Tilt) */
.map-view-controls {
    position: fixed;
    bottom: 70px;
    left: 10px;
    display: none;  /* ซ่อนโดย default */
    flex-direction: column;
    gap: 10px;
    z-index: 999;
}
.map-view-controls.show {
    display: flex;  /* แสดงเมื่อมี class show */
}

/* Auto Rotate Button */
.auto-rotate-button {
    position: fixed;
    bottom: 120px;
    left: 10px;
    background: white;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.2s;
}
.auto-rotate-button:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}
.auto-rotate-button:active {
    transform: scale(0.95);
}
.auto-rotate-button i {
    color: #666;
    font-size: 18px;
}
.auto-rotate-button.active {
    background: #e8f5e9;
}
.auto-rotate-button.active i {
    color: #4caf50;
}

/* Toggle button for view controls */
.view-controls-toggle {
    position: fixed;
    bottom: 70px;
    left: 10px;
    background: white;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
}
.view-controls-toggle:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}
.view-controls-toggle:active {
    transform: scale(0.95);
}
.view-controls-toggle i {
    color: #666;
    font-size: 20px;
}
.view-controls-toggle.active {
    background: #e3f2fd;
    bottom: 390px;  /* เลื่อนขึ้นไปเหนือ panel (2 groups * 160px + spacing + my location = ~390px) */
}
.view-controls-toggle.active i {
    color: #2196f3;
}
.view-control-group {
    background: white;
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    overflow: hidden;
}
.view-control-button {
    background: white;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #666;
    font-size: 16px;
    font-weight: bold;
}
.view-control-button:last-child {
    border-bottom: none;
}
.view-control-button:hover {
    background: #f8f9fa;
}
.view-control-button:active {
    background: #e9ecef;
}
.view-control-button i {
    font-size: 18px;
}
.view-control-label {
    font-size: 10px;
    color: #999;
    text-align: center;
    padding: 2px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

/* Map positioning */
#map {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100% - 50px);
    z-index: 1;
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #666;
    padding: 8px;
    transition: all 0.3s;
    cursor: pointer;
}

.nav-item.active {
    color: #1a73e8;
}

.nav-item:hover {
    color: #1a73e8;
    background-color: #f8f9fa;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 12px;
    font-weight: 400;
}

/* User Dropdown Button */
#userDropdownContainer {
    margin-right: 15px;
}

#userDropdown {
    padding: 8px 14px;
    transition: all 0.3s ease;
    border-radius: 8px;
    border: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

#userDropdown:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

#userDropdown:active {
    transform: scale(0.95);
}

#userDropdown i {
    font-size: 27px;
    line-height: 1;
}

/* Dropdown header for user name */
.dropdown-header {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

/* Drawing Tools - Increase icon size by 50% */
.gm-style .gmnoprint div[role="button"] {
    transform: scale(1.5);
    transform-origin: center;
}

.gm-style .gmnoprint {
    padding: 10px;
}

/* Adjust button positions on mobile to avoid overlapping with bottom-nav */
@media (max-width: 991px) {
    .my-location-button {
        bottom: 90px !important; /* 70px (nav height) + 20px spacing */
    }

    .view-controls-toggle {
        bottom: 140px !important; /* 70px (nav height) + 70px spacing */
    }

    .auto-rotate-button {
        bottom: 190px !important; /* 70px (nav height) + 120px spacing */
    }

    .view-controls-toggle.active {
        bottom: 460px !important; /* 390px + 70px for bottom-nav */
    }

    .map-view-controls {
        bottom: 140px !important; /* Same as toggle button */
    }
}

/* Hide auto-rotate button on xs and sm screens */
@media (max-width: 767px) {
    .auto-rotate-button {
        display: none !important;
    }
}

/* =============================================
   RESPONSIVE DESIGN - Mobile & Tablet
   ============================================= */

/* Large & Extra Large Screens (lg, xl) - min-width: 992px */
@media (min-width: 992px) {
    .detail-popup-content {
        min-width: 80vw !important;
        min-height: 90vh !important;
        margin: 50px auto !important;
    }

    /* Media gallery - larger grid items for lg screens */
    .media-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
    }
    .media-gallery-item {
        height: 200px !important;
    }


    /* Adjust POI filter position to avoid overlapping map controls */
    .poi-filter-container {
        top: 100px;  /* navbar 60px + 40px spacing */
        left: 10px;
    }

    /* Detail popup images - 2x larger in lg */
    .detail-popup-body img {
        max-width: 200%;
    }
}

/* Extra Large Screens (xl) - min-width: 1200px */
@media (min-width: 1200px) {
    .sidebar-container {
        width: 40vw !important;
        max-width: 800px;
    }
    .sidebar-container.visible {
        transform: translateX(0) !important;
    }

    /* Detail popup width for xl and up */
    .detail-popup-content {
        min-width: 70vw !important;
        min-height: 90vh !important;
    }

    /* Detail popup images - 2x larger in xl */
    .detail-popup-body img {
        max-width: 200%;
    }
}

/* Tablet (md) - max-width: 991px */
@media (max-width: 991px) {
    /* Navbar adjustments */
    .navbar .navbar-brand {
        font-size: 10px !important;
        font-weight: 500 !important;
        line-height: 1.2 !important;
        max-width: 200px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
    }
    .navbar .navbar-brand small {
        font-size: 8px !important;
        font-weight: 300 !important;
        opacity: 0.85;
        display: block !important;
    }
    .navbar img {
        height: 28px !important;
        width: 28px !important;
        margin-right: 6px !important;
        flex-shrink: 0 !important;
    }

    /* Navbar container - force layout */
    nav.navbar {
        padding: 6px 8px !important;
        height: auto !important;
        min-height: 45px !important;
        max-height: 50px !important;
    }

    nav.navbar .container-fluid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
    }

    /* Logo container - 10% width */
    nav.navbar .container-fluid > div:first-child {
        width: 10% !important;
        min-width: 40px !important;
        max-width: 50px !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 4px 0 0 !important;
        display: flex !important;
        justify-content: flex-start !important;
        align-items: center !important;
    }

    nav.navbar .container-fluid > div:first-child img {
        margin: 0 !important;
        width: 32px !important;
        height: 32px !important;
    }

    nav.navbar .container-fluid > div:first-child .navbar-brand {
        display: none !important;
    }

    /* Title block - 60% width using searchInputContainer */
    #searchInputContainer {
        width: 60% !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    /* Hide actual search input */
    #searchInputContainer input#searchInput {
        display: none !important;
    }

    /* Add title text line 1 via CSS */
    #searchInputContainer::before {
        content: 'CITY DATA : ข้อมูลระบบบำบัดน้ำเสีย';
        white-space: nowrap;
        font-size: 9.5px;
        font-weight: 500;
        line-height: 1.3;
        color: white;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.3px;
        width: 100%;
        margin-bottom: 1px;
    }

    /* Add title text line 2 via CSS */
    #searchInputContainer::after {
        content: 'เทศบาลเมืองพิบูลมังสาหาร';
        white-space: nowrap;
        font-size: 8px;
        font-weight: 400;
        line-height: 1.2;
        color: rgba(255, 255, 255, 0.9);
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.3px;
        width: 100%;
    }

    /* Show search icon button in sm/xs */
    #searchIconButton {
        display: flex !important;
    }

    /* Search icon button - 10% width */
    #searchIconButton {
        width: 10% !important;
        min-width: 35px !important;
        max-width: 45px !important;
        flex: 0 0 auto !important;
        margin: 0 19px 0 0 !important;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        background: transparent !important;
        border: none !important;
        color: white !important;
        cursor: pointer !important;
        font-size: 16px !important;
    }

    #searchIconButton:hover {
        color: #ddd !important;
        transform: scale(1.1);
    }


    /* User menu container - 20% width */
    nav.navbar .container-fluid > #userMenuContainer {
        width: 20% !important;
        min-width: 80px !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 4px 0 0 !important;
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
    }

    /* Navbar brand text */
    .navbar .navbar-brand {
        white-space: normal !important;
        line-height: 1.1 !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    /* Login button and user menu styling */
    #loginButton {
        font-size: 10px !important;
        padding: 4px 8px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
        margin-right: 0 !important;
    }

    #loginButton i {
        font-size: 11px !important;
        margin-right: 3px !important;
    }

    #userDropdownContainer {
        margin-right: 10px !important;
    }

    #userDropdown {
        padding: 0 !important;
        width: 48px !important;
        height: 48px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: 0 !important;
    }

    #userDropdown:hover {
        background-color: rgba(255, 255, 255, 0.2) !important;
    }

    #userDropdown i {
        font-size: 28px !important;
        margin: 0 !important;
        line-height: 1 !important;
    }

    #userDisplayName {
        display: none !important;
        white-space: nowrap !important;
    }

    /* POI Filter Container */
    .poi-filter-container {
        top: 120px !important;
        left: 10px;
        padding: 8px;
        max-width: calc(100% - 10px);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        display: flex !important;
        pointer-events: none !important;
    }
    .poi-filter-container * {
        pointer-events: auto !important;
    }

    /* Map search input responsive */
    .search-input-wrapper {
        flex: 1 1 auto;
        max-width: 65vw !important;
        order: 2 !important;
    }

    .map-search-input {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Filter icon and tags in mobile */
    .filter-icon-button {
        order: 1 !important;
        flex-shrink: 0;
    }

    .filter-tags-container {
        order: 3 !important;
        width: 100% !important;
        flex-basis: 100% !important;
    }

    .poi-filter-container.sidebar-open {
        left: 5px;
    }
    .poi-filter-dropdown {
        min-width: 100%;
        max-width: 100%;
    }
    .filter-tags-container {
        max-width: 100% !important;
        background-color: rgba(0, 0, 0, 0) !important;
        pointer-events: none !important;
    }
    .filter-tags-container * {
        pointer-events: auto !important;
    }
    .poi-filter-container.sidebar-open .filter-tags-container {
        max-width: 100% !important;
    }

    /* Search Sidebar */
    .search-sidebar {
        width: 300px;
        top: 160px !important;  /* Below search input in tablet view */
        height: calc(100% - 160px) !important;
    }

    /* Detail Popup */
    .detail-popup-content {
        width: 90%;
        max-width: 600px;
        margin: 20px auto;
    }
}

/* Mobile (sm) - max-width: 767px */
@media (max-width: 767px) {
    /* Navbar - stack vertically */
    .navbar {
        height: auto !important;
        padding: 8px 0 !important;
    }
    .navbar .container-fluid {
        flex-direction: column;
        gap: 10px;
    }
    .navbar .d-flex {
        width: 100%;
        justify-content: center;
    }
    .navbar .ms-auto {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100%;
        padding: 0 10px;
    }
    .navbar .navbar-brand {
        font-size: 13px !important;
        text-align: center;
    }
    .navbar .navbar-brand small {
        font-size: 10px !important;
    }
    .navbar img {
        height: 30px !important;
    }

    /* Map positioning - adjust for taller navbar */
    #map {
        top: 50px;
        height: calc(100% - 50px);
    }

    /* POI Filter Container */
    .poi-filter-container {
        top: 180px;
        left: 5px;
        right: 5px;
        padding: 6px;
        max-width: calc(100% - 10px);
        background: transparent !important;
        box-shadow: none !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        z-index: 1600 !important;
        display: flex !important;
        pointer-events: none !important;
    }
    .poi-filter-container * {
        pointer-events: auto !important;
    }

    /* Map search input responsive */
    .search-input-wrapper {
        flex: 1 1 auto !important;
        max-width: 65vw !important;
        order: 2 !important;
    }

    /* Filter tags container - ปรับความกว้าง */
    .filter-tags-container {
        order: 3 !important;
        width: 100% !important;
        flex-basis: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        background-color: rgba(0, 0, 0, 0) !important;
        pointer-events: none !important;
    }
    .filter-tags-container * {
        pointer-events: auto !important;
    }
    .filter-tags-container::-webkit-scrollbar {
        height: 0px !important;
        display: none !important;
    }

    /* Search Sidebar */
    .search-sidebar {
        width: 100%;
        max-width: 55vw;
        top: 200px !important;  /* Below search input and filter controls */
        height: calc(100% - 200px) !important;
    }

    /* Search Card */
    .search-card {
        padding: 12px;
    }
    .search-card-title {
        font-size: 14px;
    }
    .search-card-detail {
        font-size: 12px;
    }
    .search-card-thumbnail {
        height: 120px;
    }

    /* Info Sidebar (manage form) */
    .sidebar-container {
        width: 100%;
        right: -100%;
    }
    .sidebar-container.visible {
        right: 0;
    }

    /* Detail Popup */
    .detail-popup-content {
        width: 95%;
        max-width: 100%;
        margin: 10px auto;
        max-height: calc(100vh - 20px);
        height: auto;
        overflow-y: auto;
    }
    .detail-popup-header h2 {
        font-size: 18px;
    }
    .detail-popup-body {
        overflow-x: hidden;
    }

    /* Detail sections - mobile adjustments */
    .detail-section {
        padding: 12px;
    }

    .detail-info-item {
        flex-direction: column;
        gap: 6px;
    }

    .detail-label,
    .detail-value {
        text-align: left;
    }

    /* Media Gallery - ปรับขนาดสำหรับ sm */
    .media-gallery {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .media-gallery-item {
        height: 250px !important;
    }
    .media-gallery-item:hover {
        transform: scale(1.02) !important;
    }
    .media-gallery-item:hover img,
    .media-gallery-item:hover video {
        transform: scale(1.05) !important;
    }

    /* Info Window */
    .info-window-content {
        min-width: 180px;
        max-width: 180px;
    }

    /* Photo Viewer - sm */
    .photo-viewer-content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 100%;
        width: 100%;
        max-height: 80vh;
        padding: 0 5px;
    }
    .photo-viewer-content img {
        width: 100%;
        max-height: 80vh;
    }
    .photo-viewer-close {
        top: 10px;
        right: 10px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }
    .photo-viewer-title {
        top: 15px;
        font-size: 16px;
        padding: 10px 20px;
        max-width: calc(100% - 100px);
        left: 10px;
        transform: none;
    }
    .photo-viewer-tag {
        top: 55px;
        font-size: 13px;
        padding: 5px 14px;
    }
    .photo-viewer-counter {
        bottom: 20px;
        font-size: 14px;
        padding: 8px 16px;
    }
    .photo-viewer-metadata {
        bottom: 60px;
        max-width: 90%;
    }
    .photo-viewer-caption {
        font-size: 14px;
        padding: 8px 16px;
    }
    .photo-viewer-nav {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    .photo-viewer-prev {
        left: 15px;
    }
    .photo-viewer-next {
        right: 15px;
    }
}

/* Extra Small Mobile (xs) - max-width: 575px */
@media (max-width: 575px) {
    /* Navbar */
    .navbar .navbar-brand {
        font-size: 12px !important;
    }
    .navbar .navbar-brand small {
        font-size: 9px !important;
    }

    /* Search Sidebar */
    .search-sidebar {
        max-width: 55vw;
        top: 160px !important;  /* Below search input in xs view */
        height: calc(100% - 160px) !important;
    }

    /* POI Filter Container */
    .poi-filter-container {
        top: 120px !important;
        left: 10px !important;
        background: transparent !important;
        box-shadow: none !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        z-index: 1600 !important;
        display: flex !important;
        pointer-events: none !important;
    }
    .poi-filter-container * {
        pointer-events: auto !important;
    }

    /* Filter Icon Button - ปรับขนาดสำหรับ xs */
    .filter-icon-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
        order: 1 !important;
    }

    /* Map search input responsive */
    .search-input-wrapper {
        flex: 1 1 auto !important;
        max-width: 65vw !important;
        order: 2 !important;
    }

    /* Dropdown - ปรับตำแหน่งและขนาดสำหรับ xs */
    .poi-filter-dropdown {
        top: 48px;
        min-width: 260px;
        max-width: 85vw;
    }

    /* Filter tags container */
    .filter-tags-container {
        order: 3 !important;
        width: 100% !important;
        flex-basis: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        background-color: rgba(0, 0, 0, 0) !important;
        pointer-events: none !important;
    }
    .filter-tags-container * {
        pointer-events: auto !important;
    }
    .filter-tags-container::-webkit-scrollbar {
        height: 0px !important;
        display: none !important;
    }

    /* POI Filter */
    .filter-tag {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Search Results Header */
    .search-results-header {
        padding: 10px;
        font-size: 14px;
    }

    /* Buttons */
    .btn-sm {
        font-size: 11px;
        padding: 4px 10px;
    }

    /* Form in sidebar */
    .sidebar-container h3 {
        font-size: 16px;
    }
    .sidebar-container .form-label {
        font-size: 13px;
    }
    .sidebar-container .form-control,
    .sidebar-container .form-select {
        font-size: 13px;
    }

    /* Quill Editor - xs */
    .ql-toolbar.ql-snow {
        font-size: 12px;
    }
    .ql-container.ql-snow {
        font-size: 13px;
    }
    .ql-editor {
        min-height: 120px;
    }

    /* Detail Popup */
    .detail-popup-content {
        width: 98%;
        margin: 5px auto;
        padding: 15px;
        height: auto;
    }
    .detail-popup-header h2 {
        font-size: 16px;
    }

    /* Media Gallery - ปรับขนาดสำหรับ xs */
    .media-gallery {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .media-gallery-item {
        height: 200px !important;
    }
    .media-gallery-item:hover {
        transform: scale(1.01) !important;
    }
    .media-gallery-item:hover img,
    .media-gallery-item:hover video {
        transform: scale(1.03) !important;
    }

    /* Photo Viewer - xs */
    .photo-viewer-content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 100%;
        width: 100%;
        max-height: 75vh;
        padding: 0 5px;
    }
    .photo-viewer-content img {
        width: 100%;
        max-height: 75vh;
    }
    .photo-viewer-close {
        top: 10px;
        right: 10px;
        font-size: 28px;
        width: 38px;
        height: 38px;
    }
    .photo-viewer-title {
        top: 12px;
        font-size: 14px;
        padding: 8px 16px;
        max-width: calc(100% - 120px);
        left: 10px;
        transform: none;
    }
    .photo-viewer-tag {
        top: 50px;
        font-size: 12px;
        padding: 4px 12px;
    }
    .photo-viewer-counter {
        bottom: 15px;
        font-size: 13px;
        padding: 6px 14px;
    }
    .photo-viewer-metadata {
        bottom: 50px;
        max-width: 95%;
    }
    .photo-viewer-caption {
        font-size: 13px;
        padding: 6px 12px;
    }
    .photo-viewer-nav {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
    .photo-viewer-prev {
        left: 10px;
    }
    .photo-viewer-next {
        right: 10px;
    }
}
