/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

/* Map Container */
#map {
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Legend Styles - Top Left, Compact */
.legend {
    position: absolute;
    top: 12px;
    left: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #1D3557 0%, #457B9D 100%);
    color: white;
    cursor: pointer;
}

.legend-header h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.legend-toggle {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.legend-toggle::after {
    content: '';
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    padding: 2.5px;
    transform: rotate(45deg);
    margin-top: -2px;
}

.legend.collapsed .legend-toggle::after {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.legend-content {
    padding: 6px 8px;
    max-height: 280px;
    overflow-y: auto;
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.legend.collapsed .legend-content {
    max-height: 0;
    padding: 0 8px;
    overflow: hidden;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 5px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    transition: background 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.legend-item:hover {
    background: #f5f7fa;
}

.legend-item:hover .legend-link-icon {
    opacity: 1;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.legend-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    flex: 1;
}

.legend-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #457B9D;
    opacity: 0.5;
    transition: opacity 0.15s ease;
    margin-left: 6px;
}

/* Layer Control Styles - Bottom Left */
.layer-control {
    position: absolute;
    bottom: 24px;
    left: 12px;
    z-index: 1000;
}

.layer-icon {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
}

.layer-icon svg {
    width: 16px;
    height: 16px;
    color: #1D3557;
}

.layer-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.layer-options {
    position: absolute;
    bottom: 0;
    left: 40px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    padding: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: all 0.2s ease;
}

.layer-control:hover .layer-options {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.layer-option {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.layer-option:hover {
    background: #f5f7fa;
}

.layer-option input {
    display: none;
}

.layer-option input:checked + .layer-label {
    color: #1D3557;
    font-weight: 600;
}

.layer-option input:checked ~ .layer-label::before {
    background: #1D3557;
}

.layer-label {
    font-size: 10px;
    font-weight: 500;
    color: #666;
    position: relative;
    padding-left: 14px;
}

.layer-label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #1D3557;
    transition: background 0.15s ease;
}

/* Attribution Footer - Compact, Semi-transparent */
.attribution {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
}

.attribution .dev-text {
    font-size: 9px;
    font-weight: 500;
    color: #666;
}

.attribution .dev-name {
    font-size: 9px;
    font-weight: 600;
    background: linear-gradient(135deg, #5FA275 0%, #3d8b5a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.copy-btn svg {
    width: 10px;
    height: 10px;
    color: #457B9D;
}

.copy-text {
    font-size: 9px;
    font-weight: 500;
    color: #5FA275;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.copy-text.show {
    opacity: 1;
}

/* Compact Tooltip Styles */
.leaflet-tooltip {
    background: white;
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    padding: 8px 10px;
    font-family: 'Inter', sans-serif;
    max-width: 220px;
}

.leaflet-tooltip::before {
    display: none;
}

.tooltip-content {
    text-align: left;
}

.tooltip-state {
    font-size: 11px;
    font-weight: 700;
    color: #1D3557;
    margin-bottom: 4px;
    display: block;
}

.tooltip-message {
    font-size: 10px;
    font-weight: 400;
    color: #555;
    line-height: 1.4;
}

.tooltip-consulate {
    font-weight: 600;
    color: #457B9D;
}

/* Hide default Leaflet attribution */
.leaflet-control-attribution {
    display: none !important;
}

/* Custom Popup Styles */
.custom-popup .leaflet-popup-content-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.custom-popup .leaflet-popup-content {
    margin: 12px 14px;
}

.custom-popup .leaflet-popup-tip {
    background: white;
}

.custom-popup a:hover {
    text-decoration: underline !important;
}

/* Custom scrollbar for legend */
.legend-content::-webkit-scrollbar {
    width: 4px;
}

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

.legend-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.legend-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .legend {
        top: 10px;
        left: 10px;
        min-width: 120px;
    }

    .layer-control {
        bottom: 20px;
        left: 10px;
    }

    .layer-options {
        left: 0;
        bottom: 40px;
        flex-direction: column;
    }

    .attribution {
        padding: 5px 10px;
    }

    .attribution span {
        font-size: 8px;
    }
}
