/* Loading Overlay */
.im-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.im-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.im-loading-spinner {
    text-align: center;
}

.im-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.im-loading-spinner p {
    font-size: 16px;
    font-weight: 500;
    color: #667eea;
    margin: 0;
}

/* Map Container */
.im-map-wrapper {
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: relative;
}

.im-map-container {
    display: flex;
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Sidebar */
.im-sidebar {
    width: 350px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
}

.im-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: visible;
}

.im-sidebar.collapsed .im-sidebar-header h2 {
    opacity: 0;
    pointer-events: none;
}

.im-sidebar.collapsed .im-search-box,
.im-sidebar.collapsed .im-categories-list {
    display: none;
}

.im-sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.im-sidebar.collapsed .im-sidebar-header {
    padding: 0;
    background: transparent;
    width: 0;
    height: 0;
    overflow: visible;
}

.im-sidebar-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    transition: opacity 0.3s ease;
}

.im-sidebar-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.im-sidebar.collapsed .im-sidebar-toggle {
    position: absolute;
    top: 20px;
    left: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
}

.im-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.im-sidebar.collapsed .im-sidebar-toggle:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: scale(1.1);
}

/* Search Box */
.im-search-box {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.im-search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.im-search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.im-search-box i {
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 20px;
}

/* Categories List */
.im-categories-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Tree Structure */
.im-tree-item {
    margin-bottom: 2px;
}

.im-tree-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    transition: all 0.2s;
    cursor: pointer;
}

.im-tree-header:hover {
    background: #f5f5f5;
}

.im-tree-header.active {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.im-tree-header.active .im-tree-name,
.im-tree-header.active .im-tree-count {
    color: white;
}

.im-tree-toggle {
    background: none;
    border: none;
    padding: 0;
    margin-right: 8px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: transform 0.2s;
}

.im-tree-header.active .im-tree-toggle {
    color: white;
}

.im-tree-toggle i {
    font-size: 20px;
}

.im-tree-spacer {
    display: inline-block;
    width: 20px;
    margin-right: 8px;
}

.im-tree-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    object-fit: contain;
}

.im-tree-name {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    flex: 1;
}

.im-tree-count {
    margin-left: 8px;
    color: #999;
    font-size: 12px;
}

.im-tree-children {
    margin-left: 0;
}

/* Tree Points/Items */
.im-tree-item-point {
    margin-bottom: 2px;
}

.im-tree-point-header {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.im-tree-point-header:hover {
    background: #f5f5f5;
}

.im-tree-item-point.active .im-tree-point-header {
    background: #667eea;
    color: white;
}

.im-tree-point-header i {
    font-size: 16px;
    margin-right: 10px;
    color: #667eea;
}

.im-tree-item-point.active .im-tree-point-header i {
    color: white;
}

.im-tree-point-name {
    font-size: 13px;
    color: #555;
    font-weight: 400;
}

.im-tree-item-point.active .im-tree-point-name {
    color: white;
    font-weight: 500;
}

/* Map Content */
.im-map-content {
    flex: 1;
    position: relative;
}

#im-map {
    width: 100%;
    height: 100%;
}

/* Map Controls */
.im-map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.im-control-btn {
    background: white;
    border: 2px solid #ccc;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.im-control-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Popup Styles */
.im-popup {
    min-width: 250px;
    max-width: 350px;
}

.im-popup-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.im-popup-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.im-popup-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* Popup Content/Description from WYSIWYG */
.im-popup-content {
    font-size: 14px;
    color: #444;
    line-height: 1.6;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.im-popup-content p {
    margin: 10px 0;
}

.im-popup-content h1,
.im-popup-content h2,
.im-popup-content h3,
.im-popup-content h4,
.im-popup-content h5,
.im-popup-content h6 {
    margin: 15px 0 10px 0;
    color: #333;
    font-weight: 600;
}

.im-popup-content h1 { font-size: 20px; }
.im-popup-content h2 { font-size: 18px; }
.im-popup-content h3 { font-size: 16px; }
.im-popup-content h4 { font-size: 15px; }
.im-popup-content h5 { font-size: 14px; }
.im-popup-content h6 { font-size: 13px; }

.im-popup-content ul,
.im-popup-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.im-popup-content li {
    margin: 5px 0;
}

.im-popup-content a {
    color: #667eea;
    text-decoration: none;
}

.im-popup-content a:hover {
    text-decoration: underline;
}

.im-popup-content strong {
    font-weight: 600;
    color: #333;
}

.im-popup-content em {
    font-style: italic;
}

.im-popup-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 10px 0;
}

.im-popup-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 15px;
    margin: 15px 0;
    color: #666;
    font-style: italic;
}

.im-popup-details {
    font-size: 13px;
    color: #555;
    margin-bottom: 10px;
}

.im-popup-details p {
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.im-popup-details i {
    color: #667eea;
    font-size: 16px;
}

.im-popup-details a {
    color: #667eea;
    text-decoration: none;
}

.im-popup-details a:hover {
    text-decoration: underline;
}

.im-popup-link {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: transform 0.2s;
}

.im-popup-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 15px;
}

.leaflet-popup-content {
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .im-map-container {
        flex-direction: column;
        height: auto;
    }

    .im-sidebar {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .im-sidebar.collapsed {
        height: 60px;
    }

    .im-map-content {
        height: 400px;
    }

    .im-categories-list {
        max-height: 200px;
    }
}

/* Scrollbar Styling */
.im-categories-list::-webkit-scrollbar {
    width: 8px;
}

.im-categories-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.im-categories-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.im-categories-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Marker Cluster Customization */
.marker-cluster-small {
    background-color: rgba(102, 126, 234, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(102, 126, 234, 0.8);
    color: white;
    font-weight: 700;
}

.marker-cluster-medium {
    background-color: rgba(118, 75, 162, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(118, 75, 162, 0.8);
    color: white;
    font-weight: 700;
}

.marker-cluster-large {
    background-color: rgba(241, 128, 23, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.8);
    color: white;
    font-weight: 700;
}

/* Report Problem Button */
.im-report-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.im-report-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.im-report-btn i {
    font-size: 18px;
}

/* Report Problem Modal */
.im-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.im-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.im-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.im-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.im-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.im-modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.im-modal-body {
    padding: 20px;
}

.im-modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.im-modal-body textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
}

.im-modal-body textarea:focus {
    outline: none;
    border-color: #667eea;
}

.im-modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.im-modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.im-modal-btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.im-modal-btn-cancel:hover {
    background: #e5e7eb;
}

.im-modal-btn-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.im-modal-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.im-modal-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Hide Leaflet Routing Machine instructions panel */
.leaflet-routing-container {
    display: none !important;
}

.leaflet-control-container .leaflet-routing-container {
    display: none !important;
}

/* Ensure road polylines are visible and clickable */
.leaflet-interactive {
    cursor: pointer;
}

/* Style for routing error messages (hide them) */
.leaflet-routing-error {
    display: none !important;
}
