/* ========================================
   BUS PILOT - ENHANCEMENTS CSS v3
   Speed indicator, heading marker, night mode,
   route progress, skip button, PWA banner,
   enhanced header
   ======================================== */

/* ========================================
   HEADER MIGLIORATO
   ======================================== */

.header {
    background: linear-gradient(180deg, rgba(10, 22, 40, 0.95) 0%, rgba(15, 39, 68, 0.9) 100%) !important;
    padding: 0 !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border-bottom: none !important;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-wrapper {
    position: relative;
    font-size: 1.6rem;
    line-height: 1;
}

.header-logo-icon {
    display: block;
}

.header-live-dot {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: #ff1744;
    border-radius: 50%;
    border: 2px solid rgba(10, 22, 40, 0.95);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

.header-titles {
    display: flex;
    flex-direction: column;
}

.header h1 {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    background: linear-gradient(135deg, #ffffff 0%, #e0e8f0 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    margin: 0;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
}

.header-clock {
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

/* Striscia bandiera italiana sotto l'header */
.header-italian-stripe {
    height: 3px;
    background: linear-gradient(90deg,
            #009246 0%, #009246 33.33%,
            #ffffff 33.33%, #ffffff 66.66%,
            #CE2B37 66.66%, #CE2B37 100%);
    opacity: 0.8;
}

/* ========================================
   BANNER INSTALLAZIONE PWA
   ======================================== */

.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
}

.pwa-install-banner.show .pwa-install-card {
    transform: translateY(0);
    opacity: 1;
}

.pwa-install-banner.show .pwa-install-overlay {
    opacity: 1;
}

.pwa-install-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.pwa-install-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, #1a2d4a 0%, #0f2744 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px 24px 28px 28px;
    padding: 32px 24px 24px;
    box-shadow:
        0 -4px 40px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.pwa-close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.pwa-close-btn:hover {
    color: white;
}

.pwa-install-icon {
    margin-bottom: 16px;
}

.pwa-install-icon img {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.pwa-install-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.pwa-install-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
    line-height: 1.5;
}

.pwa-install-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.pwa-step {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}

.pwa-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: linear-gradient(135deg, #2979ff, #1565c0);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

.pwa-install-action {
    width: 100%;
    padding: 14px 24px;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #00c853, #009624);
    color: white;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 4px 20px rgba(0, 200, 83, 0.3);
}

.pwa-install-action:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0, 200, 83, 0.4);
}

.pwa-install-action:active {
    transform: scale(0.98);
}

.pwa-install-later {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: color 0.2s;
    font-family: inherit;
}

.pwa-install-later:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   INDICATORE VELOCITÀ
   ======================================== */

.speed-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    margin: 8px 0;
    background: rgba(15, 39, 68, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    transition: all 0.3s ease;
    animation: slideInFromTop 0.3s ease-out;
}

.speed-display {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.speed-value {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    color: rgba(255, 255, 255, 0.9);
    transition: color 0.3s ease;
    font-variant-numeric: tabular-nums;
}

.speed-unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 2px;
}

/* Colori velocità */
.speed-indicator.speed-slow .speed-value {
    color: #40c4ff;
}

.speed-indicator.speed-normal .speed-value {
    color: #00e676;
}

.speed-indicator.speed-fast .speed-value {
    color: #ffab00;
}

.speed-indicator.speed-normal,
.speed-indicator.speed-fast {
    animation: speedPulse 2s ease-in-out infinite;
}

@keyframes speedPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 200, 83, 0.15);
    }

    50% {
        box-shadow: 0 0 16px 2px rgba(0, 200, 83, 0.1);
    }
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   MARKER UTENTE CON DIREZIONE
   ======================================== */

.user-marker-container {
    background: transparent !important;
    border: none !important;
}

.user-marker-arrow {
    width: 36px;
    height: 36px;
    position: relative;
    transition: transform 0.5s ease-out;
}

.user-marker-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: #2979ff;
    border: 3px solid #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 0 4px rgba(41, 121, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.user-marker-heading {
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 14px solid #2979ff;
    transform: translateX(-50%);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    z-index: 1;
}

.user-marker-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: rgba(41, 121, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: markerPulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes markerPulse {
    0% {
        width: 16px;
        height: 16px;
        opacity: 1;
    }

    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* ========================================
   PULSANTE SALTA FERMATA
   ======================================== */

.skip-btn {
    background: linear-gradient(135deg, #ff9100 0%, #ff6d00 100%) !important;
    color: white !important;
    border: none !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.skip-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 145, 0, 0.4);
}

.skip-btn:active {
    transform: scale(0.95);
}

/* ========================================
   MODALITÀ NOTTURNA AUTOMATICA
   ======================================== */

body.night-mode {
    --bg-primary: #050d18;
    --bg-secondary: #0a1628;
    --bg-tertiary: #0f1e33;
    --glass-bg: rgba(5, 13, 24, 0.85);
    --text-primary: rgba(255, 255, 255, 0.85);
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-muted: rgba(255, 255, 255, 0.35);
}

body.night-mode .speed-value {
    opacity: 0.8;
}

body.night-mode .map-container {
    filter: brightness(0.7);
}

body.night-mode .header {
    opacity: 0.85;
}

body.night-mode .control-panel {
    background: rgba(5, 13, 24, 0.9) !important;
}

body.night-mode .btn {
    opacity: 0.9;
}

body {
    transition: background-color 1s ease, color 0.5s ease;
}

/* ========================================
   LISTA FERMATE MIGLIORATA
   ======================================== */

.stop-item {
    transition: all 0.3s ease;
}

.stop-item.next {
    background: rgba(41, 121, 255, 0.12) !important;
    border-left: 3px solid #2979ff;
}

.stop-item.passed {
    opacity: 0.45;
}

.stop-item.passed .stop-item-name {
    text-decoration: line-through;
}

@keyframes skipBounce {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(5px);
    }

    50% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }

    100% {
        transform: translateX(0);
    }
}

.stop-item.skipping {
    animation: skipBounce 0.4s ease;
}

/* ========================================
   CONTROL PANEL MIGLIORATO
   ======================================== */

.control-panel {
    margin-top: 74px !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    .speed-value {
        font-size: 2.2rem;
    }

    .speed-indicator {
        padding: 8px 12px;
    }

    .pwa-install-card {
        padding: 24px 16px 20px;
        border-radius: 20px 20px 24px 24px;
    }

    .pwa-install-title {
        font-size: 1.2rem;
    }

    .header-content {
        padding: 10px 12px 6px;
    }

    .header h1 {
        font-size: 1.05rem !important;
    }

    .skip-btn {
        padding: 3px 8px !important;
        font-size: 0.7rem !important;
    }
}