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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Controls Section */
.controls {
    background: white;
    color: #1f2937;
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e7eb;
    z-index: 1000;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.control-group label {
    font-weight: 500;
    font-size: 14px;
    color: #6b7280;
}

#mapSelector {
    padding: 8px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: white;
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
}

#mapSelector:hover:not(:disabled) {
    background-color: #f9fafb;
    border-color: #3b82f6;
    
}

#mapSelector:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#mapSelector:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.info {
    font-size: 13px;
    line-height: 1.6;
    background-color: #f3f4f6;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.info strong {
    font-size: 14px;
    display: block;
    margin-bottom: 5px;
    color: #111827;
}

.info small {
    color: #6b7280;
}

/* Map Container */
#map {
    flex: 1;
    height: 100%;
    background-color: #e5e5e5;
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.loading.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    position: absolute;
    margin-top: 80px;
    color: white;
    font-size: 16px;
    font-weight: 500;
}

/* MapLibre GL overrides for better appearance */
.maplibregl-canvas {
    outline: none;
}

.maplibregl-ctrl-group {
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.maplibregl-ctrl button {
    border: none;
}

.maplibregl-ctrl-attrib {
    background-color: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px);
}

.maplibregl-ctrl-scale {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 4px;
    padding: 2px 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls {
        padding: 12px 15px;
    }

    .control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #mapSelector {
        width: 100%;
        min-width: unset;
    }

    .info {
        font-size: 12px;
    }

    .control-group label {
        font-size: 13px;
    }
}

@media (min-width: 769px) {
    .control-group {
        margin-bottom: 0;
    }

    .controls {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .info {
        margin-bottom: 0;
        max-width: 50%;
    }
}

/* Print styles */
@media print {
    .controls {
        display: none;
    }

    #map {
        height: 100vh;
    }
}

/* ==================== EDITING TOOLBAR ==================== */

.editing-toolbar {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 320px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    overflow: hidden;
}

.editing-toolbar.collapsed {
    width: 60px;
    overflow: hidden;
}

.editing-toolbar.collapsed .toolbar-header {
    justify-content: center;
    padding: 15px 10px;
}

.toolbar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 10px 10px 0 0;
}

.toolbar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.toolbar-content {
    padding: 15px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    overflow-x: hidden;
}

.tool-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.tool-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tool-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mode toggle styles */
.mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-btn {
    background: #f5f5f5;
    border: 2px solid transparent;
    padding: 12px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.mode-btn span {
    font-size: 24px;
    display: block;
}

.mode-btn .mode-text {
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.mode-btn small {
    font-size: 10px;
    color: #666;
    text-align: center;
}

.mode-btn:hover {
    background: #e8e8ff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.mode-btn.active {
    background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
    color: white;
    border-color: #51cf66;
    box-shadow: 0 4px 12px rgba(81, 207, 102, 0.4);
}

.mode-btn.active .mode-text,
.mode-btn.active small {
    color: white;
}

.mode-btn.active::before {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 14px;
    font-weight: bold;
    color: white;
}

.tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool-btn {
    background: #f5f5f5;
    border: 2px solid transparent;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.tool-btn span {
    font-size: 18px;
}

.tool-btn:hover {
    background: #e8e8ff;
    border-color: #667eea;
    transform: translateY(-2px);
}

.tool-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.style-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.style-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.style-row label {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    min-width: 60px;
}

.style-row input[type="color"] {
    width: 50px;
    height: 35px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.style-row input[type="color"]:hover {
    border-color: #667eea;
}

.style-row input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #e0e0e0 0%, #667eea 100%);
    outline: none;
    -webkit-appearance: none;
}

.style-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.style-row input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

.style-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.style-row input[type="range"]::-moz-range-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

.style-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.style-row input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.style-row span {
    font-size: 12px;
    font-weight: 500;
    color: #667eea;
    min-width: 35px;
    text-align: right;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-btn {
    background: #ff6b6b;
    color: white;
}

.clear-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.save-btn {
    background: #51cf66;
    color: white;
}

.save-btn:hover {
    background: #40c057;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(81, 207, 102, 0.3);
}

.export-btn {
    background: #4dabf7;
    color: white;
}

.export-btn:hover {
    background: #339af0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

.info-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info-box small {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

/* Custom marker styles */
.custom-marker {
    cursor: pointer;
}

/* Responsive adjustments for editing toolbar */
@media (max-width: 768px) {
    .editing-toolbar {
        right: 10px;
        top: 80px;
        width: 280px;
    }

    .mode-toggle {
        grid-template-columns: 1fr;
    }

    .mode-btn {
        padding: 10px 8px;
    }

    .mode-btn span {
        font-size: 20px;
    }

    .tool-buttons {
        grid-template-columns: 1fr;
    }

    .toolbar-content {
        max-height: calc(100vh - 200px);
    }
}

/* Scrollbar styles for toolbar */
.toolbar-content::-webkit-scrollbar {
    width: 6px;
}

.toolbar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.toolbar-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.toolbar-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Measurement display box */
.measurement-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #4dabf7;
    font-size: 13px;
    line-height: 1.6;
}

.measurement-box strong {
    color: #1976d2;
}

.measurement-box small {
    color: #666;
    font-size: 11px;
}

/* Coordinates display */
.coordinates-display {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.coord-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.coord-label {
    font-weight: 600;
    color: #667eea;
}


/* Map Attribution */
.map-attribution {
    position: fixed;
    bottom: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 0;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
    font-size: 11px;
    color: #6b7280;
    width: 100%;
    right: 0;
    text-align: center;
}

.map-attribution a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.map-attribution a:hover {
    text-decoration: underline;
}
.coord-item span:last-child {
    color: #333;
    min-width: 70px;
}

/* Measurement marker styles */
.measurement-marker {
    cursor: pointer;
}

/* Responsive adjustments for coordinates */
@media (max-width: 768px) {
    .coordinates-display {
        top: 70px;
        padding: 8px 12px;
        font-size: 11px;
        gap: 15px;
        flex-wrap: wrap;
    }


    .map-attribution {
        font-size: 10px;
        padding: 6px 10px;
    }
    .coord-item span:last-child {
        min-width: 60px;
    }
}

/* Instruction box styles */
.instruction-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #fff3e0 100%);
    padding: 12px 15px;
    border-radius: 8px;
    border-left: 4px solid #ff9800;
    font-size: 13px;
    line-height: 1.6;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 152, 0, 0);
    }
}

.instruction-box strong {
    color: #e65100;
}

/* Drawing actions */
.drawing-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finish-btn {
    background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
    color: white;
}

.finish-btn:hover {
    background: linear-gradient(135deg, #40c057 0%, #2b8a3e 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(81, 207, 102, 0.4);
}

.undo-btn {
    background: linear-gradient(135deg, #ffd43b 0%, #fab005 100%);
    color: #333;
}

.undo-btn:hover {
    background: linear-gradient(135deg, #fcc419 0%, #f08c00 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(250, 176, 5, 0.4);
}

.cancel-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #fa5252 100%);
    color: white;
}

.cancel-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e03131 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

/* Welcome tooltip */
.welcome-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tooltip-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tooltip-content h3 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 24px;
}

.tooltip-content p {
    margin: 10px 0;
    color: #666;
}

.tooltip-content ol {
    margin: 15px 0;
    padding-left: 25px;
    color: #333;
}

.tooltip-content li {
    margin: 8px 0;
    line-height: 1.6;
}

.close-welcome-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    transition: all 0.3s ease;
}

.close-welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Responsive welcome tooltip */
@media (max-width: 768px) {
    .tooltip-content {
        margin: 20px;
        padding: 20px;
        max-width: 90%;
    }

    .tooltip-content h3 {
        font-size: 20px;
    }

    .tooltip-content li {
        font-size: 14px;
    }
}

/* Overview Mini Map */
.overview-map {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 250px;
    height: 200px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 999;
    transition: all 0.3s ease;
}

.overview-map:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.overview-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 28px;
}

.close-overview-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.close-overview-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#overviewMapContainer {
    width: 100%;
    height: calc(100% - 28px);
    position: relative;
}

/* Viewport box on overview map */
.overview-viewport-box {
    border: 2px solid #ff6b6b;
    background-color: rgba(255, 107, 107, 0.2);
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}
