:root {
    --primary-color: #1976D2;
    --primary-dark: #0D47A1;
    --primary-light: #BBDEFB;
    --accent-color: #FF5722;
    --text-primary: #212121;
    --text-secondary: #757575;
    --divider-color: #BDBDBD;
    --background-color: #F5F5F5;
    --surface-color: #FFFFFF;
    --error-color: #D32F2F;
    --success-color: #388E3C;
    --warning-color: #FFA000;
    --info-color: #0288D1;
    --border-radius: 8px;
    --shadow-small: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-medium: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --shadow-large: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

body {
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
    color: var(--text-primary);
    overflow: hidden;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    box-shadow: var(--shadow-small);
    z-index: 1000;
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 1.5rem;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 500;
}

.location-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.location-toggle:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.location-toggle i {
    font-size: 1.2rem;
}

.search-container {
    display: flex;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: var(--border-radius);
    background-color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

#search-button {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    padding: 0 12px;
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
}

/* Map */
#map {
    flex-grow: 1;
    width: 100%;
    z-index: 1;
}

/* Info Panel */
#info-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    max-height: 70%;
    overflow-y: auto;
    box-shadow: var(--shadow-large);
    z-index: 1000;
    border-radius: 20px 20px 0 0;
    transition: transform var(--transition-speed) ease;
    padding-bottom: env(safe-area-inset-bottom); /* For iOS devices */
}

.panel-handle {
    width: 100%;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
}

.handle-bar {
    width: 40px;
    height: 5px;
    background-color: var(--divider-color);
    border-radius: 3px;
}

#stop-info, #route-info {
    padding: 0 16px 16px;
}

#stop-name, #route-name {
    font-size: 1.3rem;
    margin: 10px 0;
    color: var(--text-primary);
}

.time-now {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.bus-time {
    padding: 15px;
    margin: 8px 0;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-small);
    border-left: 4px solid var(--primary-color);
}

.bus-time.clickable {
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
}

.bus-time.clickable:active {
    transform: scale(0.98);
}

.bus-time.clickable::after {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
}

.time-info {
    font-weight: bold;
    color: var(--primary-color);
}

/* Route Info */
.route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.back-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color var(--transition-speed);
}

.back-btn:hover {
    background-color: var(--primary-light);
}

.route-stop {
    padding: 12px;
    margin: 5px 0;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    border-left: 4px solid transparent;
    box-shadow: var(--shadow-small);
}

.route-stop:hover {
    background-color: var(--primary-light);
    border-left: 4px solid var(--primary-color);
}

.route-stop.current {
    background-color: var(--primary-light);
    font-weight: bold;
    border-left: 4px solid var(--accent-color);
}

.route-stop.current::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-color: var(--accent-color);
    border-radius: 50%;
    border: 3px solid white;
}

.route-stops-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--divider-color);
    padding-bottom: 15px;
}

.route-stops-list::-webkit-scrollbar {
    width: 6px;
}

.route-stops-list::-webkit-scrollbar-thumb {
    background-color: var(--divider-color);
    border-radius: 3px;
}

.trip-time-info {
    background-color: var(--primary-light);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
}

.trip-time-info p {
    margin: 5px 0;
}

.route-info-details {
    background-color: var(--surface-color);
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--info-color);
    box-shadow: var(--shadow-small);
}

.route-info-details p {
    margin: 5px 0;
}

/* Location Panel */
#location-panel {
    position: absolute;
    top: 70px;
    right: 10px;
    background-color: var(--surface-color);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    z-index: 1000;
    width: 250px;
    max-width: 80%;
}

#location-panel h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color var(--transition-speed);
}

.location-btn:hover {
    background-color: var(--primary-dark);
}

.location-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 5px;
}

#location-status {
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Message Box */
#message-box {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--surface-color);
    padding: 10px 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    animation: fadeInDown 0.3s;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

#message-icon {
    font-size: 1.2rem;
    color: var(--info-color);
}

#close-message {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    margin-left: auto;
}

/* Loading Spinner */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--primary-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

.loading-spinner.large {
    width: 50px;
    height: 50px;
    border-width: 4px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity var(--transition-speed);
}

.loader-content {
    text-align: center;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Leaflet Custom Styles */
.leaflet-tooltip {
    font-size: 12px;
    padding: 6px 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    box-shadow: var(--shadow-small);
    font-weight: 500;
}

.bus-stop-marker {
    color: var(--primary-color) !important;
}

.leaflet-control-zoom {
    margin-bottom: 60px !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    #info-panel {
        max-height: 75%;
    }

    .route-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .back-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #2196F3;
        --primary-dark: #1976D2;
        --primary-light: #1E293B;
        --text-primary: #E2E8F0;
        --text-secondary: #94A3B8;
        --divider-color: #475569;
        --background-color: #0F172A;
        --surface-color: #1E293B;
    }

    #search-input {
        background-color: rgba(30, 41, 59, 0.9);
        color: var(--text-primary);
    }

    #search-button {
        color: var(--primary-color);
    }

    .page-loader {
        background-color: rgba(15, 23, 42, 0.9);
    }

    .leaflet-tooltip {
        background-color: var(--surface-color);
        color: var(--text-primary);
    }
}
/* Stili per il controllo mappa */
.map-style-control {
    background: none;
    border: none;
}

.map-style-control button {
    width: 36px;
    height: 36px;
    background-color: white;
    border: none;
    border-radius: 4px;
    box-shadow: var(--shadow-small);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Modalità scura */
body.dark-map .stop-icon {
    border-color: #ffffff;
    background-color: #1e293b;
}

body.dark-map .current-stop {
    background-color: var(--accent-color);
    border-color: #1e293b;
}

body.dark-map .leaflet-tooltip {
    background-color: rgba(30, 41, 59, 0.9);
    color: #fff;
    border: 1px solid #3388ff;
}

body.dark-map .map-style-control button {
    background-color: #1e293b;
    color: white;
}

body.dark-map {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.dark-map .loading-container p {
    color: #e2e8f0;
}
