/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Map container */
#map-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map title overlay */
.map-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    text-align: center;
    max-width: 90%;
    backdrop-filter: blur(5px);
}

.map-title h1 {
    font-size: 1.5em;
    margin-bottom: 5px;
    color: #2c3e50;
    font-weight: 600;
}

.map-title p {
    font-size: 0.9em;
    color: #666;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Help button (question mark icon) */
.help-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.help-icon:hover {
    background: #2980b9;
    transform: scale(1.1);
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e3e3e3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 1.1em;
    color: #666;
}

/* Progress information */
#progress-info {
    margin-top: 20px;
    width: 300px;
}

#progress-bar {
    width: 0%;
    background: #3498db;
    height: 4px;
    border-radius: 2px;
    transition: width 0.3s ease;
    margin-bottom: 10px;
}

#progress-text {
    font-size: 0.9em;
    color: #555;
    text-align: center;
    margin: 0;
}

/* Controls panel */
.controls-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
    min-width: 250px;
}

.control-group {
    margin-bottom: 15px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9em;
}

.control-group select,
.control-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
    background: white;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.calculate-button {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.calculate-button:hover {
    background: #2980b9;
}

.calculate-button:active {
    background: #21618c;
}

.calculate-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Search button */
.search-button {
    padding: 8px 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-button:hover {
    background: #229954;
}

.search-button:active {
    background: #1e8449;
}

/* Search results dropdown */
.search-results {
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: none;
}

.search-results.visible {
    display: block;
}

.search-result-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-item strong {
    display: block;
    color: #2c3e50;
    margin-bottom: 3px;
}

.search-result-item small {
    color: #666;
    font-size: 0.85em;
}

.search-error {
    padding: 10px;
    color: #e74c3c;
    font-size: 0.9em;
}

.search-loading {
    padding: 10px;
    color: #666;
    font-size: 0.9em;
    text-align: center;
}

/* Legend styles */
.legend {
    position: absolute;
    bottom: 30px;
    left: 30px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
}

.legend h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 0.9em;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.8em;
}

.legend-color {
    width: 20px;
    height: 15px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .map-title {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        padding: 10px 15px;
    }

    .map-title h1 {
        font-size: 1.2em;
    }

    .controls-panel {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }

    .legend {
        bottom: 20px;
        left: 10px;
        right: 10px;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

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

@media (max-width: 480px) {
    .map-title {
        padding: 8px 12px;
    }

    .map-title h1 {
        font-size: 1.1em;
    }

    .map-title p {
        font-size: 0.8em;
    }

    .controls-panel {
        padding: 15px;
    }
}

/* Leaflet popup custom styling */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    font-family: inherit;
    line-height: 1.4;
}

/* Custom hex tooltip styles */
.hex-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    pointer-events: none;
    white-space: nowrap;
}

/* Dark mode toggle styling */
.control-group label[for="dark-mode-toggle"] {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.control-group label[for="dark-mode-toggle"] input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
}

/* Metro label fade-in animation */
@keyframes fadeInLabel {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.metro-label-animated {
    animation-fill-mode: forwards;
}

/* Hexagon hover tooltip styling */
.hex-tooltip {
    background: rgba(0, 0, 0, 0.85) !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(8px) !important;
    pointer-events: none;
}

.hex-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.85) !important;
}

/* Fade in animation for clear button */
@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Clear zones button (dimple on circle) */
.clear-zones-button {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
}

.clear-zones-button:hover {
    background: #ff4444;
    color: #fff;
    transform: scale(1.2) rotate(90deg);
    box-shadow: 0 6px 16px rgba(255,68,68,0.6);
}

/* Circle border animation */
.hex-grid-border {
    transition: opacity 0.3s ease;
}

/* Help sidebar */
.help-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    overflow-y: auto;
    transition: right 0.3s ease;
    backdrop-filter: blur(10px);
}

.help-sidebar.open {
    right: 0;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.help-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3em;
}

.close-help-button {
    width: 32px;
    height: 32px;
    border: none;
    background: #e74c3c;
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: all 0.2s ease;
}

.close-help-button:hover {
    background: #c0392b;
    transform: rotate(90deg);
}

.help-content {
    padding: 20px;
}

.help-content section {
    margin-bottom: 25px;
}

.help-content section:last-child {
    margin-bottom: 0;
}

.help-content h4 {
    color: #2c3e50;
    margin: 0 0 10px 0;
    font-size: 1.1em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.help-content p {
    color: #555;
    line-height: 1.6;
    margin: 0 0 10px 0;
}

.help-content ul,
.help-content ol {
    color: #555;
    line-height: 1.8;
    margin: 10px 0;
    padding-left: 25px;
}

.help-content li {
    margin-bottom: 8px;
}

.help-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 4px;
}

.help-legend-color {
    display: inline-block;
    width: 30px;
    height: 15px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    vertical-align: middle;
}

/* Responsive help sidebar */
@media (max-width: 768px) {
    .help-sidebar {
        width: 100%;
        right: -100%;
    }
}

/* SVG checkered flag marker */
.destination-flag-svg {
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.4));
}

.destination-flag-svg svg {
    overflow: visible;
}