/* Optimized Rail Network Map Styles */

/* Container and Map */
#rail-map-container {
    position: relative;
    width: 100%;
    height: 600px;
    min-height: 400px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
}

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

/* Download Panel - Outside Map */
.download-panel {
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.download-panel h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 18px;
    font-weight: 600;
}

.download-panel p {
    margin: 0 0 20px 0;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
}

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

.selected-area-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px;
}

.selected-area-info p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: #495057;
}

.area-details {
    font-size: 13px;
    color: #6c757d;
}

.download-options {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px;
}

.download-options label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.format-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.download-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.download-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.instructions {
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 16px;
    margin-top: 10px;
}

.instructions p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: #495057;
}

.instructions ol {
    margin: 0;
    padding-left: 20px;
    color: #6c757d;
    font-size: 13px;
}

.instructions li {
    margin-bottom: 4px;
}

/* Info Panel */
.info-panel {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 8px;
    min-width: 300px;
    max-width: 400px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    z-index: 1000;
}

.info-panel.show {
    display: block;
}

.panel-header {
    background: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2;
}

.panel-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6c757d;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.info-content {
    padding: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.info-content h5 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
}

.info-content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.info-content td {
    padding: 4px 8px;
    border-bottom: 1px solid #f8f9fa;
    vertical-align: top;
}

.info-content td:first-child {
    font-weight: 600;
    color: #495057;
    width: 40%;
}

/* Loading Indicator */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    font-size: 14px;
    color: #495057;
}

#loading-indicator {
    display: none;
}

#loading-indicator.active {
    display: flex !important;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Leaflet Control Customization */
.leaflet-control-layers {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Draw Control Styles */
.leaflet-draw-toolbar {
    margin-top: 10px;
}

.leaflet-draw-toolbar a {
    background-color: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
}

.leaflet-draw-toolbar a:hover {
    border-color: #007bff;
}

/* Responsive Design */
@media (max-width: 768px) {
    #rail-map-container {
        height: 400px;
    }
    
    .info-panel {
        bottom: 5px;
        left: 5px;
        min-width: 250px;
        max-width: 300px;
    }
    
    .download-panel {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    #rail-map-container {
        height: 350px;
    }
    
    .info-panel {
        min-width: 200px;
        max-width: 250px;
    }
    
    .panel-header h4 {
        font-size: 13px;
    }
    
    .download-panel h4 {
        font-size: 16px;
    }
}

/* Print Styles */
@media print {
    .info-panel,
    .leaflet-control-container,
    .download-panel {
        display: none !important;
    }
    
    #rail-map-container {
        height: 500px;
        border: 1px solid #000;
    }
}