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

:root {
    --primary-color: #8B6F47;
    --secondary-color: #D4A574;
    --accent-color: #FFD700;
    --bg-light: #FAF6F1;
    --bg-dark: #5C4033;
    --success: #4CAF50;
    --danger: #F44336;
    --info: #2196F3;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0e8df;
    color: #333;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Map */
#map {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    cursor: url('x.png') 16 16, crosshair;
}

.leaflet-container {
    background: #f0e8df;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Overlay Base Styling */
.overlay {
    position: fixed;
    z-index: 100;
    pointer-events: none;
}

.overlay > * {
    pointer-events: auto;
}

/* Top Center Search Overlay */
.overlay-top-center {
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
}

.search-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.search-input-overlay {
    width: 320px;
    padding: 14px 24px;
    border: none;
    border-radius: 32px;
    font-size: 18px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    transition: all 0.3s ease;
    background: #800000;
    color: white;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.search-input-overlay:focus {
    outline: none;
    background: #6b0000;
    box-shadow: 0 6px 20px rgba(128, 0, 0, 0.35);
}

.search-input-overlay::placeholder {
    color: rgba(255, 255, 255, 0.65);
    font-weight: bold;
}

/* Top Right Zoom Controls */
.overlay-top-right {
    top: 24px;
    right: 24px;
}

@media (max-width: 768px) {
    .overlay-top-right {
        display: none;
    }
}

.zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-zoom {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #800000;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-zoom:hover {
    background: #600000;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.btn-zoom:active {
    transform: scale(0.95);
}

/* Bottom Center Icons Button */
.overlay-bottom-center {
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
}

/* Bottom Left Add Icon Button */
.overlay-bottom-left {
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

/* Bottom Right Download Button */
.overlay-bottom-right {
    bottom: 24px;
    right: 24px;
}

.btn-icon-action {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #800000;
    color: white;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-action:hover:not(:disabled) {
    background: #600000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    transform: translateY(-2px);
}

.btn-icon-action:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-icon-action:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Loading spinner for download button */
.btn-icon-action.loading {
    position: relative;
    color: transparent;
}

.btn-icon-action.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Leaflet zoom control override - hide default */
.leaflet-top,
.leaflet-bottom {
    z-index: 50;
}

.leaflet-control-zoom {
    display: none;
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 8px;
    z-index: 1000;
    font-size: 16px;
    font-weight: 600;
}

/* Icon Picker Panel */
.icon-picker-panel {
    position: fixed;
    bottom: 92px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: rgba(250, 246, 241, 0.97);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    border: 1.5px solid rgba(128, 0, 0, 0.25);
    width: 300px;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.icon-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-picker-item:hover {
    background: rgba(128, 0, 0, 0.08);
    border-color: rgba(128, 0, 0, 0.3);
    transform: scale(1.05);
}

.icon-picker-item canvas {
    width: 40px;
    height: 40px;
    border-radius: 4px;
}

/* Placement Preview (bottom left) */
.placement-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(250, 246, 241, 0.95);
    border-radius: 10px;
    padding: 6px 6px;
    border: 1.5px solid #800000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.placement-preview-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.placement-preview-icon img,
.placement-preview-icon canvas {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #8B6F47;
}

.cancel-placement-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid #800000;
    background: #800000;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    transition: background 0.2s;
}

.cancel-placement-btn:hover {
    background: #600000;
}
