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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    overflow: hidden;
}

.header {
    background-color: #2e7d32;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header h1 {
    font-size: 24px;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-btn {
    color: white;
    background-color: rgba(255,255,255,0.2);
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    border: none;
}

.header-btn:hover {
    background-color: rgba(255,255,255,0.3);
}

.admin-link {
    color: white;
    text-decoration: none;
    padding: 8px 20px;
    background-color: rgba(255,255,255,0.2);
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.admin-link:hover {
    background-color: rgba(255,255,255,0.3);
}

.container {
    display: flex;
    height: calc(100vh - 64px);
}

.sidebar {
    width: 320px;
    background-color: white;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.filter-section {
    padding: 20px;
}

.filter-section h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4CAF50;
}

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

.filter-group label {
    display: block;
    font-weight: bold;
    color: #555;
    margin-bottom: 8px;
}

.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.filter-group select {
    cursor: pointer;
}

.filter-group select option {
    padding: 5px;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-container input {
    flex: 1;
}

.range-container span {
    color: #666;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #999;
    color: white;
}

.btn-secondary:hover {
    background-color: #888;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    margin-top: 5px;
    background-color: #e0e0e0;
    color: #333;
}

.btn-small:hover {
    background-color: #d0d0d0;
}

.stats-summary {
    margin-top: 20px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 4px;
    text-align: center;
}

.stats-summary p {
    color: #666;
    font-size: 14px;
}

.map-container {
    flex: 1;
    position: relative;
}

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

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 14px;
    line-height: 1.2;
}

.popup-content h3 {
    margin: 0 0 10px 0;
    color: #2e7d32;
    font-size: 16px;
}

.popup-content p {
    margin: 5px 0;
    color: #555;
}

.popup-content strong {
    color: #333;
}

.tree-icon {
    width: 30px;
    height: 30px;
}

.custom-tree-marker {
    background: none;
    border: none;
    filter:
    drop-shadow(0 0 7px #E69F00)
    drop-shadow(0 0 7px #E69F00)
    drop-shadow(0 0 7px #E69F00)
    drop-shadow(0 0 7px #E69F00);
}

.custom-tree-marker .tree-icon {
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
    transition: transform 0.2s;
}

.custom-tree-marker:hover .tree-icon {
    transform: scale(1.3);
}

.unplaced-trees-box {
    position: absolute;
    top: 80px;
    right: 10px;
    width: 280px;
    max-height: calc(100vh - 100px); /* Adjust max-height to not overflow viewport */
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    overflow: hidden; /* Changed from visible */
    z-index: 1000;
    display: none; /* JS will toggle this */
    flex-direction: column; /* Ensure vertical layout */
}

.unplaced-trees-box h4 {
    margin: 0;
    padding: 12px 15px;
    background: #ff9800;
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid #f57c00;
}

.unplaced-tree-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 5px;
}

.unplaced-tree-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 3px 0;
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.unplaced-tree-item:hover {
    background: #fff3cd;
    border-color: #ffb300;
    transform: translateX(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.unplaced-tree-icon {
    width: 28px;
    height: 28px;
    margin-right: 10px;
    flex-shrink: 0;
}

.unplaced-tree-info {
    flex: 1;
    min-width: 0;
}

.unplaced-tree-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unplaced-tree-variety {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unplaced-tree-id {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}



.unplaced-tree-popup {
    position: absolute;
    top: 50%;
    right: calc(100% + 16px);
    transform: translateY(-50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
    padding: 13px 16px;
    min-width: 200px;
    max-width: 90vw;
    z-index: 10000;
    border: 2px solid #ff9800;
}

.unplaced-tree-popup .popup-content {
    font-size: 14px;
    line-height: 1.25;
}

.unplaced-tree-popup h3 {
    margin: 0 0 10px 0;
    color: #ff9800;
    font-size: 16px;
}

.unplaced-tree-popup::before {
    content: "";
    position: absolute;
    top: 93%;
    right: -14px;
    transform: translateY(-100%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 14px solid white;
    z-index: 1;
}

.unplaced-tree-list::-webkit-scrollbar {
    width: 6px;
}

.unplaced-tree-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.unplaced-tree-list::-webkit-scrollbar-thumb {
    background: #ff9800;
    border-radius: 3px;
}

.unplaced-tree-list::-webkit-scrollbar-thumb:hover {
    background: #f57c00;
}

@media print {
    .sidebar {
        display: none !important;
    }
    
    .header {
        display: none !important;
    }
    
    .unplaced-trees-box{
        display: none !important;
    }
    
    .map-container {
        width: 100vw !important;
        height: 100vh !important;
    }
    
    body {
        margin: 0;
        padding: 0;
    }
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablets */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .filter-section {
        padding: 15px;
    }
}

/* Mobile - hide sidebar by default, show as overlay */
@media (max-width: 768px) {
    .header {
        padding: 12px 15px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .header-btn,
    .admin-link {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .container {
        height: calc(100vh - 54px);
        flex-direction: column;
    }
    
    /* Make sidebar overlay on mobile */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 54px;
        width: 85%;
        max-width: 320px;
        height: calc(100vh - 54px);
        z-index: 2000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* Add toggle button */
    .filter-toggle {
        position: fixed;
        top: 64px;
        left: 10px;
        background: #4CAF50;
        color: white;
        border: none;
        border-radius: 4px;
        padding: 10px 15px;
        font-size: 14px;
        font-weight: bold;
        z-index: 1500;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .map-container {
        width: 100%;
        height: 100%;
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 54px;
        left: 0;
        width: 100%;
        height: calc(100vh - 54px);
        background: rgba(0,0,0,0.5);
        z-index: 1999;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Filter section adjustments */
    .filter-section {
        padding: 15px;
    }
    
    .filter-section h2 {
        font-size: 1.1rem;
    }
    
    .filter-group input[type="text"],
    .filter-group input[type="number"],
    .filter-group select,
    button {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
        padding: 10px;
    }
    
    /* Unplaced trees box adjustments */
    .unplaced-trees-box {
        width: calc(100% - 20px);
        max-width: 300px;
        bottom: 10px;
        right: 10px;
        left: 10px;
        margin: 0 auto;
    }
    
    .unplaced-tree-popup {
        /* On mobile, show popup above the item instead */
        top: auto;
        bottom: calc(100% + 8px);
        right: 0;
        left: 0;
        transform: none;
        max-width: 100%;
    }
    
    .unplaced-tree-popup::before {
        /* Arrow points down instead of right */
        top: 100%;
        right: 50%;
        transform: translateX(50%);
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-top: 14px solid white;
        border-bottom: none;
    }
    
    /* Larger touch targets for tree markers */
    .custom-tree-marker .tree-icon {
        width: 36px;
        height: 36px;
    }
    
    /* Leaflet popup adjustments */
    .leaflet-popup-content {
        margin: 12px;
        font-size: 13px;
    }
    
    .popup-content h3 {
        font-size: 15px;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }
    
    .header-btn,
    .admin-link {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .sidebar {
        width: 90%;
    }
    
    .filter-section h2 {
        font-size: 1rem;
    }
    
    .unplaced-trees-box {
        width: calc(100% - 10px);
        bottom: 5px;
        right: 5px;
        left: 5px;
    }
}

/* Landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .unplaced-trees-box {
        max-height: 150px;
    }
    
    .unplaced-tree-list {
        max-height: 100px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    
    /* Disable hover effects on touch devices */
    .custom-tree-marker:hover .tree-icon {
        transform: none;
    }
    
    /* Make interactive elements slightly larger */
    .unplaced-tree-item {
        padding: 10px;
    }
}