/* iPhone Notch/Dynamic Island Support */
@supports (padding: env(safe-area-inset-top)) {
    html, body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Adjust mobile topbar for notch */
    .mobile-topbar {
        padding-top: calc(env(safe-area-inset-top) + 10px);
        height: calc(80px + env(safe-area-inset-top));
        padding-left: calc(20px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
    }
    
    /* Adjust body padding for pages with mobile topbar */
    @media (max-width: 768px) {
        body {
            padding-top: calc(80px + env(safe-area-inset-top)) !important;
        }
    }
}

/* Mobile Top Bar and Menu Component CSS */
.mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(135deg, rgba(248, 249, 250, 0.85), rgba(233, 236, 239, 0.85));
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.3);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
}

.mobile-page-title {
    color: black;
    font-size: 18px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    text-align: center;
    pointer-events: none;
}

.mobile-logo {
    width: 60px;
    height: 60px;
}

.mobile-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mobile-hamburger {
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    z-index: 1002;
}

.mobile-hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: black;
    transition: 0.3s;
    border-radius: 2px;
}

.mobile-hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.mobile-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.mobile-hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: linear-gradient(135deg, rgba(129, 187, 39, 0.9), rgba(106, 156, 33, 0.9));
    backdrop-filter: blur(4px);
    border: 1px solid rgba(129, 187, 39, 0.3);
    z-index: 1001;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3), inset 1px 0 0 rgba(255,255,255,0.2);
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 30px 20px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-menu-header h3 {
    color: white;
    margin: 0;
    font-size: 24px;
    font-weight: bold;
}

.close-btn {
    color: white;
    font-size: 30px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mobile-menu-content {
    padding: 20px 0;
}

.mobile-menu-content a {
    display: block;
    color: white;
    font-size: 16px;
    padding: 15px 30px;
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: all 0.3s;
    margin: 0;
}

.mobile-menu-content a:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: white;
    transform: translateX(10px);
}

.mobile-menu-content a.active {
    background: rgba(255,255,255,0.2);
    border-left-color: white;
    font-weight: 600;
}

.mobile-menu-content a i {
    margin-right: 15px;
    width: 20px;
}

.mobile-prenota-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    margin: 20px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    border-left: 4px solid white !important;
}

.mobile-prenota-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: translateX(0) !important;
}

@media (max-width: 768px) {
    .mobile-topbar {
        display: flex;
    }
    
    body {
        padding-top: 80px;
    }
}

/* Scroll Progress Indicator with Scooter (same as desktop but for mobile) */
.mobile-topbar .scroll-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.mobile-topbar .scroll-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #81bb27, #6a9c21);
    width: 0%;
    transition: width 0.1s ease-out;
}

.mobile-topbar .scroll-scooter {
    position: absolute;
    bottom: -12px;
    left: 0%;
    width: 30px;
    height: 22px;
    background-image: url('/static/images/scooter-entrata.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: left 0.1s ease-out, transform 0.3s ease;
    z-index: 1002;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transform: scaleX(-1); /* Start facing right */
}

.mobile-topbar .scroll-scooter.reverse {
    transform: scaleX(1); /* Reverse the initial flip to face left */
}

@media (min-width: 769px) {
    .mobile-topbar {
        display: none !important;
    }
    
    .mobile-menu {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
}