/* ========================================
   MIGLIORIE PROFESSIONALI BUSITALIA
   ======================================== */

/* ========================================
   FULLSCREEN TRACKING OVERLAY
   ======================================== */

.tracking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #f5f7fa;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.tracking-overlay.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

/* Header con pulsante indietro */
.tracking-header {
    background: linear-gradient(135deg, #009246 0%, #CE2B37 100%);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10001;
}

.back-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-button:hover {
    background: white;
    color: #CE2B37;
    transform: translateX(-5px);
}

.back-button:active {
    transform: translateX(-3px);
}

.tracking-route-name {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pannello statistiche fullscreen */
.tracking-stats-panel {
    background: white;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10000;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: #009246;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 146, 70, 0.2);
}

.stat-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #009246;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pannello stato fullscreen */
.tracking-status-panel {
    background: white;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    z-index: 10000;
}

.fullscreen-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

.fullscreen-status .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* Mappa fullscreen */
.fullscreen-map {
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Responsive mobile */
@media (max-width: 768px) {
    .tracking-header {
        padding: 0.75rem;
    }
    
    .back-button {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .tracking-route-name {
        font-size: 1rem;
    }
    
    .tracking-stats-panel {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.5rem;
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        font-size: 1.5rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.2rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.7rem;
    }
}

/* Animazione entrata */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Layout Compatto Durante Tracking */
.control-panel.tracking-active {
    padding: 0.5rem 1rem;
}

.control-panel.tracking-active .select-container {
    margin-bottom: 0.5rem;
}

.control-panel.tracking-active .status-container {
    margin-bottom: 0.5rem;
}

/* Nascondi elementi non necessari durante tracking */
.tracking-active .search-input {
    display: none;
}

.tracking-active #gpx-select {
    pointer-events: none;
    opacity: 0.7;
}

/* Mappa Full Screen Button */
.map-fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
    background: white;
    border: 2px solid #CE2B37;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: none;
}

.tracking-active .map-fullscreen-btn {
    display: block;
}

.map-fullscreen-btn:hover {
    background: #CE2B37;
    color: white;
    transform: scale(1.1);
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #CE2B37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Statistiche Tracking */
.tracking-stats {
    background: linear-gradient(135deg, #009246 0%, #CE2B37 100%);
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    text-align: center;
}

.tracking-active .tracking-stats {
    display: grid;
}

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem;
    border-radius: 5px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
    display: block;
}

/* Pulsanti Migliorati */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10001;
    animation: slideInRight 0.3s ease;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid #009246;
}

.toast.error {
    border-left: 4px solid #CE2B37;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #999;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Zoom Controls Migliorati */
.leaflet-control-zoom {
    border: 2px solid #CE2B37 !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    color: #CE2B37 !important;
    font-weight: 700 !important;
}

.leaflet-control-zoom a:hover {
    background: #CE2B37 !important;
    color: white !important;
}

/* Marker Personalizzato */
.custom-marker {
    background: #CE2B37;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: #e9ecef;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #009246 0%, #CE2B37 100%);
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Tooltip Migliorato */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 10002;
    white-space: nowrap;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Smooth Transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus States Migliorati */
input:focus,
select:focus,
button:focus {
    outline: 2px solid #009246;
    outline-offset: 2px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Card Elevation */
.card-elevated {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.card-elevated:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .tracking-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-item:last-child {
        grid-column: 1 / -1;
    }
    
    .toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Print Styles */
@media print {
    .control-panel,
    .btn,
    .toast,
    .loading-overlay {
        display: none !important;
    }
    
    .map-container {
        height: 100vh !important;
    }
}
