/* === CSS Variables & Reset === */
:root {
    --primary-color: #4a90e2;
    --primary-dark: #3a7bc8;
    --secondary-color: #50c878;
    --background: #0f0f1e;
    --surface: #1a1a2e;
    --surface-light: #25254a;
    --text-primary: #ffffff;
    --text-secondary: #b8b8d1;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
    --success: #50c878;
    --warning: #ffa500;
    --error: #ff4757;
    --glass-bg: rgba(26, 26, 46, 0.85);
    --glass-border: rgba(255, 255, 255, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* === Status Bar === */
.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1001;
    font-size: 14px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error);
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.cache-info {
    color: var(--text-secondary);
    font-size: 13px;
}

/* === Main Container === */
.container {
    display: flex;
    height: calc(100vh - 40px);
    margin-top: 40px;
    position: relative;
}

/* === Control Panel === */
.control-panel {
    width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 30px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.panel-header {
    margin-bottom: 30px;
}

.panel-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* === Coordinate Input === */
.coordinate-input {
    margin-bottom: 25px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.input-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Buttons === */
.btn-primary,
.btn-secondary,
.btn-action {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(74, 144, 226, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    margin-bottom: 10px;
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--primary-color);
}

.btn-action {
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 14px;
    padding: 10px 16px;
}

.btn-action:hover {
    background: var(--primary-color);
}

/* === Quick Actions === */
.quick-actions {
    margin-bottom: 30px;
}

/* === Info Section === */
.info-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.info-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.info-section ul {
    list-style: none;
}

.info-section li {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.info-section li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

/* === Map Container === */
.map-container {
    flex: 1;
    position: relative;
    background: var(--surface);
}

#map {
    width: 100%;
    height: 100%;
}

/* === Details Panel === */
.details-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 350px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateX(0);
    transition: all 0.3s ease;
}

.details-panel.hidden {
    transform: translateX(400px);
    pointer-events: none;
}

.details-panel h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--surface-light);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--error);
    transform: rotate(90deg);
}

.detail-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.detail-item:last-of-type {
    border-bottom: none;
}

.detail-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-value {
    display: block;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

.detail-value.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.detail-actions {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* === Download Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 35px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    position: relative;
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.download-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.download-estimate {
    background: var(--surface-light);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid var(--border-color);
}

.download-estimate span {
    color: var(--primary-color);
    font-weight: 600;
}

.download-progress {
    margin-bottom: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* === ESA Info === */
.esa-info {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.esa-info.hidden {
    display: none;
}

.esa-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--glass-border);
}

.esa-info h3 {
    color: var(--primary-color);
    margin-bottom: 4px;
    font-size: 18px;
}

.esa-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.esa-details {
    text-align: left;
}

.esa-detail-item {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.esa-detail-item strong {
    color: var(--text-primary);
}

/* === Responsive Design === */
@media (max-width: 1024px) {
    .control-panel {
        width: 350px;
    }

    .details-panel {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        max-height: 50vh;
    }

    .details-panel {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        width: auto;
    }

    .details-panel.hidden {
        transform: translateY(400px);
    }
}

/* === Leaflet Customization === */
.leaflet-container {
    background: var(--background);
}

.leaflet-popup-content-wrapper {
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.leaflet-popup-tip {
    background: var(--surface);
}

.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--primary-color) !important;
}

/* === Custom Marker Pulse === */
@keyframes marker-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(74, 144, 226, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0);
    }
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}