:root {
    /* Couleurs - Mode sombre */
    --bg-primary: #0a0a0f;
    --bg-secondary: #14141f;
    --bg-tertiary: #1e1e2e;
    --text-primary: #f8f8f2;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c7a;
    --accent-color: #00d4ff;
    --accent-secondary: #0099cc;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    --border-color: #252538;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --map-bg: #0b0b15;
}

[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adaeaf;
    --accent-color: #0d6efd;
    --accent-secondary: #0b5ed7;
    --success-color: #198754;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --map-bg: #e9ecef;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 0;
}

.header {
    background: var(--bg-secondary);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent-color);
}

.controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-icon.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Carte */
#map {
    height: 100%;
    width: 100%;
    background: var(--map-bg);
    z-index: 100;
}

/* Panneau d'informations */
.info-panel {
    position: absolute;
    right: 20px;
    top: 70px;
    bottom: 20px;
    width: 320px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    padding: 20px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.location-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.location-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.location-row {
    display: flex;
    gap: 8px;
}

.location-form input[type="number"],
.location-form input[type="text"] {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.85rem;
}

.location-form input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-text {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-text:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn-text-accent {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-text-accent:hover {
    background: var(--accent-secondary);
    color: white;
}

.panel-section {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
}

.panel-section h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-section h2 i {
    color: var(--accent-color);
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.data-grid-single {
    grid-template-columns: 1fr;
}

.data-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: "Courier New", monospace;
}

.crew-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crew-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.9rem;
}

.crew-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success-color);
}

.status-dot.error {
    background: var(--error-color);
    animation: none;
}

.status-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-text.connected {
    color: var(--success-color);
}

.status-text.error {
    color: var(--error-color);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-color);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--error-color);
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .info-panel {
        position: fixed;
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 10px;
        width: auto;
        max-height: 300px;
        max-width: 800px;
        margin: 0 auto;
    }

    .data-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .info-panel {
        max-height: 250px;
    }

    .data-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .info-panel {
        right: 5px;
        left: 5px;
        bottom: 5px;
        max-height: 200px;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
}

/* Style pour Leaflet en mode sombre */
[data-theme="dark"] .leaflet-container {
    background: var(--map-bg);
}

[data-theme="dark"] .leaflet-control-attribution,
[data-theme="dark"] .leaflet-control-zoom,
[data-theme="dark"] .leaflet-bar {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .leaflet-control-zoom-in,
[data-theme="dark"] .leaflet-control-zoom-out {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .leaflet-control-zoom-in:hover,
[data-theme="dark"] .leaflet-control-zoom-out:hover {
    background: var(--accent-color);
    color: white;
}

/* Icône ISS personnalisée */
.iss-icon-style {
    filter: drop-shadow(2px 2px 6px rgba(0, 212, 255, 0.7));
    transition: transform 0.3s ease;
}

.iss-icon-style.pulsing {
    animation: pulse 1.5s infinite;
}

/* Trace de l'ISS */
.iss-trail {
    stroke-dasharray: 10, 5;
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -100;
    }
}

/* Orbite théorique */
.iss-orbit {
    stroke-dasharray: 5, 5;
    opacity: 0.5;
}

/* Liste des passages */
#passList {
    margin-top: 5px;
}

#passItems {
    list-style: none;
    padding: 0;
    margin: 0;
}

#passItems li {
    padding: 6px 8px;
    margin: 2px 0;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#passItems li:nth-child(1) {
    border-left-color: var(--success-color);
    font-weight: 600;
    color: var(--text-primary);
}

#passItems li:not(:first-child) {
    opacity: 0.8;
    font-size: 0.8rem;
}

/* Altitude des passages */
.pass-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 6px 10px !important;
    margin: 3px 0 !important;
    border-radius: 4px !important;
    font-size: 0.85rem !important;
    transition: all 0.2s ease !important;
}

.pass-item.altitude-high {
    border-left: 4px solid #4ade80 !important; /* vert */
    background: var(--bg-secondary) !important;
}

.pass-item.altitude-good {
    border-left: 4px solid #fbbf24 !important; /* orange */
    background: var(--bg-secondary) !important;
}

.pass-item.altitude-medium {
    border-left: 4px solid #fb923c !important; /* orange clair */
    background: var(--bg-secondary) !important;
}

.pass-item.altitude-low {
    border-left: 4px solid #f87171 !important; /* rouge */
    background: var(--bg-secondary) !important;
    opacity: 0.7 !important;
}

.pass-item:first-child {
    font-weight: 600 !important;
}

.pass-item:first-child .pass-item {
    background: var(--bg-tertiary) !important;
}
