/* style.css - Stili principali */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.navbar-brand {
    font-weight: 600;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1rem;
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.table th {
    background-color: #f8f9fa;
    border-top: none;
}

.badge-admin {
    background-color: var(--danger-color);
}

.badge-responsabile {
    background-color: var(--warning-color);
    color: #000;
}

.badge-volontario {
    background-color: var(--success-color);
}

/* Timeline per servizi */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--primary-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -23px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2px solid white;
}

.timeline-item.completed::before {
    background-color: var(--success-color);
}

.timeline-item.in-progress::before {
    background-color: var(--warning-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    .table-responsive {
        font-size: 0.9rem;
    }
}

/* Miglioramenti per mobile */
@media (max-width: 576px) {

    /* Header più compatto */
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Card più compatte */
    .card {
        margin-bottom: 0.75rem;
        border-radius: 0.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Bottoni a larghezza piena su mobile */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Form fields più grandi per touch */
    .form-control,
    .form-select {
        padding: 0.75rem;
        font-size: 16px;
        /* Previene lo zoom automatico su iOS */
        min-height: 48px;
        /* Dimensioni touch-friendly */
    }

    /* Tabelle scrollabili con header fisso */
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        overflow: hidden;
    }

    .table-responsive table {
        margin-bottom: 0;
    }

    .table-responsive th {
        position: sticky;
        top: 0;
        background-color: var(--primary-color);
        color: white;
        z-index: 10;
        white-space: nowrap;
    }

    /* Timeline ottimizzata per mobile */
    .timeline {
        padding-left: 20px;
    }

    .timeline::before {
        left: 10px;
    }

    .timeline-item::before {
        left: -18px;
        width: 10px;
        height: 10px;
    }

    /* Badge più grandi per mobile */
    .badge {
        padding: 0.35em 0.65em;
        font-size: 0.85em;
    }

    /* Spaziature ridotte */
    .container,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Miglioramenti per modali su mobile */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 0.75rem;
    }

    /* Font size ridotti per adattamento */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Pulsanti azione fissi in basso */
    .action-buttons-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        display: flex;
        gap: 0.5rem;
    }

    .action-buttons-mobile .btn {
        flex: 1;
    }

    /* Aggiungi padding al body per evitare sovrapposizione */
    body.has-mobile-actions {
        padding-bottom: 80px;
    }

    /* Menu a hamburger migliorato */
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 1.25rem;
    }

    .navbar-collapse {
        background: white;
        padding: 1rem;
        border-radius: 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        margin-top: 0.5rem;
    }
}

/* Supporto per dispositivi con notch */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }

    .safe-area-bottom {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .action-buttons-mobile {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Ottimizzazione per tablet (orientamento orizzontale) */
@media (max-width: 992px) and (orientation: landscape) {
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
    }

    .table-responsive {
        max-height: 60vh;
    }
}

/* Miglioramenti touch per tutti i dispositivi touch */
@media (hover: none) and (pointer: coarse) {

    .btn,
    .nav-link,
    .form-check-label {
        min-height: 44px;
        /* Dimensioni minime per touch */
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Aumenta l'area di click per elementi interattivi */
    .table tbody tr {
        min-height: 44px;
    }

    .table tbody tr td {
        padding: 0.75rem 0.5rem;
    }

    /* Evita hover su mobile */
    .btn:hover {
        transform: none;
    }
}

/* Animazioni smooth per mobile */
@media (prefers-reduced-motion: no-preference) {
    .navbar-collapse.collapsing {
        transition: height 0.2s ease;
    }

    .modal.fade .modal-dialog {
        transition: transform 0.3s ease-out;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    .card {
        border: 1px solid #dee2e6;
        box-shadow: none;
    }
}

/* === OTTIMIZZAZIONI MOBILE AVANZATE === */

/* Ottimizzazioni per tablet (768px - 992px) */
@media (min-width: 769px) and (max-width: 992px) {

    /* Card più compatte per tablet */
    .card {
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    /* Bottoni più compatti per tablet */
    .btn-group-tablet {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn-group-tablet .btn {
        margin-bottom: 0.5rem;
        flex: 1;
        min-width: 120px;
    }

    /* Layout a griglia ottimizzata per tablet */
    .tablet-grid-2 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Font size ottimizzati per tablet */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    /* Timeline ottimizzata per tablet */
    .timeline {
        padding-left: 25px;
    }

    .timeline::before {
        left: 12px;
    }

    .timeline-item::before {
        left: -20px;
    }
}

/* Ottimizzazioni specifiche per servizio_dettaglio.php */
/* Header mobile specifico per dettaglio servizio */
@media (max-width: 768px) {

    /* Header mobile per dettaglio servizio */
    .servizio-header-mobile {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid var(--primary-color);
    }

    .servizio-title-mobile {
        font-size: 1.3rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }

    .servizio-meta-mobile {
        font-size: 0.85rem;
    }

    .servizio-badges-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin: 0.75rem 0;
    }

    .servizio-badges-mobile .badge {
        font-size: 0.8rem;
        padding: 0.4em 0.8em;
    }

    /* Pulsanti azione fissi in basso - versione migliorata */
    .servizio-action-buttons-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 0.75rem;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
        z-index: 1050;
        display: flex;
        gap: 0.5rem;
        border-top: 1px solid #dee2e6;
    }

    .servizio-action-buttons-mobile .btn {
        flex: 1;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
    }

    .servizio-action-buttons-mobile .btn i {
        font-size: 1.2rem;
    }

    .servizio-action-buttons-mobile .btn span {
        font-size: 0.75rem;
    }

    /* Spazio per i pulsanti fissi */
    body.has-mobile-actions {
        padding-bottom: 90px;
    }

    /* Layout a colonna singola per mobile */
    .servizio-details-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Card ottimizzate per mobile */
    .card-mobile-compact {
        margin-bottom: 0.75rem;
        border-radius: 0.75rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .card-header-mobile {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .card-body-mobile {
        padding: 1rem;
    }

    /* Layout colonne per mobile */
    .row-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .col-mobile-full {
        width: 100%;
    }

    /* Timeline ottimizzata per mobile */
    .timeline-mobile {
        padding-left: 20px;
        margin: 1rem 0;
    }

    .timeline-mobile::before {
        left: 9px;
        width: 2px;
    }

    .timeline-item-mobile {
        position: relative;
        margin-bottom: 1rem;
        padding-left: 5px;
    }

    .timeline-item-mobile::before {
        content: '';
        position: absolute;
        left: -15px;
        top: 8px;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: var(--primary-color);
        border: 2px solid white;
    }

    .timeline-item-mobile.completed::before {
        background-color: var(--success-color);
    }

    .timeline-item-mobile h6 {
        font-size: 0.95rem;
        margin-bottom: 0.25rem;
    }

    .timeline-item-mobile p {
        font-size: 0.85rem;
        margin-bottom: 0;
    }

    /* Equipaggio in grid per mobile */
    .equipaggio-grid-mobile {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Chilometraggio in grid per mobile */
    .km-grid-mobile {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        text-align: center;
    }

    .km-grid-mobile h6 {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .km-grid-mobile h4 {
        font-size: 1.2rem;
        margin-bottom: 0;
    }

    /* Percorso ottimizzato per mobile */
    .percorso-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .percorso-card-mobile {
        padding: 1rem;
        border-radius: 0.5rem;
        background: #f8f9fa;
    }
}

/* Ottimizzazioni per schermi molto piccoli (< 400px) */
@media (max-width: 400px) {
    .servizio-title-mobile {
        font-size: 1.1rem;
    }

    .servizio-meta-mobile {
        font-size: 0.8rem;
    }

    .servizio-action-buttons-mobile .btn {
        padding: 0.5rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .servizio-action-buttons-mobile .btn i {
        font-size: 1rem;
    }

    .servizio-action-buttons-mobile .btn span {
        display: none;
        /* Nascondi testo su schermi molto piccoli */
    }

    .equipaggio-grid-mobile {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .km-grid-mobile {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* Supporto per dispositivi con notch e safe areas */
@supports (padding: max(0px)) {
    .servizio-action-buttons-mobile {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    body.has-mobile-actions {
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }
}

/* Animazioni per mobile */
@media (prefers-reduced-motion: no-preference) {
    .servizio-action-buttons-mobile {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .card-mobile-compact {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .card-mobile-compact:active {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

/* Stili per orientamento landscape su mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .servizio-action-buttons-mobile {
        flex-direction: row;
        padding: 0.5rem;
    }

    .servizio-action-buttons-mobile .btn {
        min-height: 44px;
        flex-direction: row;
        gap: 0.5rem;
    }

    .servizio-action-buttons-mobile .btn span {
        display: block;
        font-size: 0.85rem;
    }

    body.has-mobile-actions {
        padding-bottom: 70px;
    }
}

/* === STILI SPECIFICI PER STAMPA === */
@media print {

    .servizio-action-buttons-mobile,
    .btn-group,
    .no-print {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .timeline-item-mobile::before {
        border: 1px solid #000;
    }
}

/* === FIX SCROLL PER DISPOSITIVI SAMSUNG === */

/* Abilita scroll fluido su tutti i dispositivi */
html {
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

body {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fix specifico per tabelle su dispositivi Samsung */
.table-responsive {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
}

/* Migliora lo scroll per elementi con contenuto scrollabile */
.scrollable-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overscroll-behavior-y: contain;
}

/* Disabilita l'effetto di rimbalzo su iOS/Android */
@media (max-width: 768px) {
    body {
        overscroll-behavior-y: none;
    }

    .table-responsive {
        overscroll-behavior-x: contain;
    }
}

/* Aggiungi questa regola per le pagine servizi */
.page-servizi .table-responsive,
.page-servizio .table-responsive {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
}