/* ===================================================================
   GoneTrack — Moodboard Design System
   Palette: Bleu Nuit #0B5B9D | Bleu Lagon #369FB1 | Jaune Moutarde #D99B38
            Glace #E1F2FB | Blanc #FFFFFF
   Fonts:  Montserrat (titles) | Inter (body)
   =================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --bleu-nuit: #0B5B9D;
    --bleu-nuit-dark: #084A80;
    --bleu-nuit-light: #3D7DB5;
    --bleu-lagon: #369FB1;
    --bleu-lagon-dark: #2A7F8E;
    --bleu-lagon-light: #5CB8C7;
    --jaune-moutarde: #D99B38;
    --jaune-moutarde-dark: #B8832E;
    --jaune-moutarde-light: #E4B565;
    --glace: #D4E9F5;
    --glace-dark: #B8D9EA;
    --white: #FFFFFF;
    --text-primary: #0B5B9D;
    --text-secondary: #5A6A78;
    --shadow-blue: rgba(11, 91, 157, 0.12);
    --shadow-blue-lg: rgba(11, 91, 157, 0.18);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 50px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    height: 100%;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Map --- */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* --- UI Container (floating panel) --- */
#ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow:
        0 4px 24px var(--shadow-blue),
        0 12px 48px var(--shadow-blue-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 360px;
    max-width: calc(100vw - 40px);
    border: 1px solid rgba(54, 159, 177, 0.1);
    animation: panelSlideIn 0.5s var(--transition-medium) both;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Panel Header (Logo + Brand) --- */
#panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

#logo-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px var(--shadow-blue));
}

#brand-text h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.02em;
}

.brand-gone {
    color: var(--bleu-nuit);
}

.brand-track {
    color: var(--bleu-lagon);
    font-weight: 600;
}

.tagline {
    font-size: 12px;
    color: var(--bleu-lagon);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* --- Connection Panel --- */
#connection-panel {
    display: flex;
    gap: 10px;
}

.input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    pointer-events: none;
    opacity: 0.6;
}

#code-input {
    width: 100%;
    padding: 12px 14px 12px 38px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--bleu-nuit);
    border: 2px solid var(--glace-dark);
    border-radius: var(--radius-md);
    background: var(--white);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#code-input::placeholder {
    color: var(--bleu-lagon-light);
    font-weight: 400;
}

#code-input:focus {
    border-color: var(--bleu-lagon);
    box-shadow: 0 0 0 4px rgba(54, 159, 177, 0.12);
}

/* --- Connect Button (Jaune Moutarde CTA) --- */
#connect-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    background: linear-gradient(135deg, var(--jaune-moutarde), var(--jaune-moutarde-dark));
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(217, 155, 56, 0.3);
    position: relative;
    overflow: hidden;
}

#connect-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}

#connect-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(217, 155, 56, 0.4);
    background: linear-gradient(135deg, var(--jaune-moutarde-light), var(--jaune-moutarde));
}

#connect-btn:hover::before {
    left: 100%;
}

#connect-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(217, 155, 56, 0.3);
}

#connect-btn:disabled {
    background: linear-gradient(135deg, #b0bac3, #9aa5af);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#connect-btn:disabled:hover::before {
    left: -100%;
}

.btn-icon {
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

#connect-btn:hover .btn-icon {
    transform: translateX(2px);
}

/* --- Status --- */
#status-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--glace);
    border-radius: var(--radius-md);
}

#status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bleu-lagon-light);
    flex-shrink: 0;
    position: relative;
}

#status-dot.connected {
    background: #4CAF50;
    animation: pulse-dot 2s infinite;
}

#status-dot.waiting {
    background: var(--jaune-moutarde);
    animation: pulse-dot 1.5s infinite;
}

#status-dot.error {
    background: #F44336;
}

@keyframes pulse-dot {
    0%, 100% {
        box-shadow: 0 0 0 0 currentColor;
    }
    50% {
        box-shadow: 0 0 0 6px transparent;
    }
}

/* Pulse with color for connected dot */
#status-dot.connected {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
    }
}

#status-dot.waiting {
    animation: pulse-amber 1.5s infinite;
}

@keyframes pulse-amber {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(217, 155, 56, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(217, 155, 56, 0);
    }
}

#status {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
}

/* --- Last Update --- */
#last-update {
    display: none;
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--glace), rgba(54, 159, 177, 0.08));
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--bleu-nuit);
    border-left: 3px solid var(--bleu-lagon);
}

/* --- Panel Footer --- */
#panel-footer {
    text-align: center;
    font-size: 11px;
    color: var(--bleu-lagon-light);
    font-weight: 500;
    letter-spacing: 0.03em;
    padding-top: 4px;
    border-top: 1px solid rgba(54, 159, 177, 0.08);
}

/* --- Leaflet overrides for brand consistency --- */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md) !important;
    box-shadow: 0 4px 16px var(--shadow-blue) !important;
    font-family: 'Inter', sans-serif !important;
}

.leaflet-popup-content {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--bleu-nuit) !important;
}

.leaflet-popup-tip {
    box-shadow: 0 2px 8px var(--shadow-blue) !important;
}

.leaflet-control-zoom a {
    color: var(--bleu-nuit) !important;
    border-color: var(--glace-dark) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--glace) !important;
    color: var(--bleu-lagon) !important;
}

/* --- Responsive for mobile --- */
@media (max-width: 480px) {
    #ui-container {
        top: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        padding: 18px;
        gap: 12px;
        border-radius: var(--radius-md);
    }

    #brand-text h1 {
        font-size: 18px;
    }

    .tagline {
        font-size: 10px;
    }

    #code-input {
        font-size: 13px;
        padding: 10px 12px 10px 36px;
    }

    #connect-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .btn-text {
        display: none;
    }

    #status {
        font-size: 12px;
    }

    #panel-footer {
        display: none;
    }
}

@media (max-width: 360px) {
    #panel-header {
        gap: 8px;
    }

    #logo-icon {
        width: 32px;
        height: 32px;
    }
}