/* Aggiungiamo queste regole in cima al tuo CSS */
:root {
  --mobile-breakpoint: 576px;
  --tablet-breakpoint: 768px;
}

/* Mappe responsive */
#itineraryMap,
#map-itinerario,
#map {
  height: 300px !important; /* Riduciamo l'altezza di default */
}

@media (min-width: 768px) {
  #itineraryMap,
  #map-itinerario,
  #map {
    height: 400px !important;
  }
}

@media (min-width: 992px) {
  #itineraryMap,
  #map-itinerario,
  #map {
    height: 500px !important; /* Manteniamo l'altezza originale su desktop */
  }
}

/* Miglioriamo i testi troncati */
.description-truncate {
  max-width: 100%;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 576px) {
  .description-truncate {
    max-width: 180px;
    white-space: nowrap;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
  }
}

/* Pulsanti più compatti su mobile */
.btn {
  padding: 0.5rem 1rem;
}

@media (max-width: 575.98px) {
  .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
  }
  
  /* Riduciamo le dimensioni delle icone su mobile */
  .vehicle-icon,
  .vehicle-icon-lg,
  .cost-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.9rem !important;
  }
}

/* Miglioriamo le card su mobile */
.card {
  margin-bottom: 1rem;
}

@media (max-width: 575.98px) {
  .card-body {
    padding: 1rem;
  }
  
  .card-title {
    font-size: 1.1rem;
  }
}

/* Accordion più compatto su mobile */
@media (max-width: 575.98px) {
  .accordion-button {
    padding: 0.75rem !important;
    font-size: 0.9rem !important;
  }
  
  .accordion-body {
    padding: 0.75rem !important;
  }
}

/* Miglioriamo le tabelle su mobile */
@media (max-width: 575.98px) {
  .table-responsive {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    width: calc(100% + 1rem);
  }
  
  .table td, .table th {
    padding: 0.5rem;
  }
}
/* Hover effects */
.hover-scale {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}
.hover-scale:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}
.hover-scale:hover .icon-wrapper {
    transform: scale(1.1);
}
.icon-wrapper {
    transition: transform 0.3s ease;
}
.btn-hover {
    transition: all 0.3s ease;
}
.btn-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Cards */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 10px;
    overflow: hidden;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Tables */
.table-hover tbody tr {
    transition: background-color 0.2s ease;
}
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.03);
}

/* Icons */
.vehicle-icon,
.vehicle-icon-lg {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(13, 110, 253, 0.1);
    border-radius: 50%;
}
.vehicle-icon {
    width: 36px;
    height: 36px;
}
.vehicle-icon-lg {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
}
.cost-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-primary);
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
}
.action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Text helpers */
.text-truncate,
.description-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.text-truncate {
    display: inline-block;
    max-width: 100%;
}
.description-truncate {
    max-width: 250px;
    cursor: help;
}

/* Inputs */
.form-control-lg, .form-select-lg {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}
@media (min-width: 768px) {
    .form-control-lg, .form-select-lg {
        font-size: 1.05rem;
    }
}
.input-group-text {
    background-color: #f8f9fa;
}

/* Accordion */
.accordion-item {
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}
.accordion-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.accordion-header {
    background-color: #ffffff;
    transition: background-color 0.2s ease;
}
.accordion-header:hover {
    background-color: #f8f9fa;
}
.accordion-button {
    font-weight: 500;
    font-size: 1rem;
    color: #212529;
    padding: 1rem 1.25rem;
    background-color: transparent;
    box-shadow: none;
}
.accordion-button:not(.collapsed) {
    color: #212529;
}
.accordion-button::after {
    filter: brightness(0.5);
}
.accordion-body {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 1.25rem;
}

/* Mappa */
#itineraryMap,
#map-itinerario,
#map {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    height: 500px !important;
    background: #f8f9fa;
    position: relative;
}
.custom-div-icon .marker-pin {
    background-color: #2563eb;
    color: white;
    font-weight: bold;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    box-shadow: 0 0 3px rgba(0,0,0,0.5);
    font-size: 14px;
    transform: translateY(6px);
}

/* Drag */
.drag-handle {
    cursor: grab;
    padding: 0 8px 0 12px;
    color: #adb5bd;
    transition: color 0.2s ease;
    font-size: 0.9rem;
}
.drag-handle:hover {
    color: #495057;
}
.drag-handle:active,
.dragging-active {
    cursor: grabbing;
    color: #212529;
    user-select: none;
}
.sortable-ghost {
    opacity: 0.6;
    background: #f0f7ff;
    border: 1px dashed #c8ebfb;
}
.sortable-drag {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: rotate(2deg);
}

/* Badge */
.custom-badge {
    min-width: 28px;
    height: 28px;
    width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border: 2px solid #e9ecef;
    font-weight: 600;
    border-radius: 50%;
    padding: 0;
    margin-right: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}
.animate-badge {
    animation: pulse 0.5s ease-in-out;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Highlight tappa */
.highlight-tappa {
    position: relative;
    overflow: hidden;
}
.highlight-tappa::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(13, 110, 253, 0.15);
    animation: highlight-fade 2s forwards;
    z-index: -1;
}
@keyframes highlight-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Paginate */
.pagination .page-link {
    background-color: #fff;
    border: none;
    transition: all 0.2s ease;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
}
.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.pagination .page-link:hover:not(.disabled):not(.active) {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}
.pagination .page-item.disabled .page-link {
    opacity: 0.5;
    pointer-events: none;
}

/* Bottoni */
.btn-outline-primary,
.btn-outline-warning,
.btn-outline-secondary,
.btn-outline-danger {
    transition: all 0.2s ease;
}

/* Note */
.note-text {
    word-break: break-word;
    font-size: 0.85rem;
    color: #495057;
}

/* Stato cronologico */
.table-warning {
    background-color: #fff3cd !important;
}
.border-warning {
    border-color: #ffc107 !important;
}
.bg-warning-subtle {
    background-color: #fff3cd !important;
}

/* Loader / errori */
.map-loader,
#route-loader,
#reorder-loader {
    display: none;
    position: absolute;
    z-index: 1000;
    background: rgba(255,255,255,0.8);
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.map-error {
    display: none;
    color: #dc3545;
    font-weight: bold;
    position: absolute;
    z-index: 1000;
    top: 10px;
    left: 10px;
    right: 10px;
    text-align: center;
    background: rgba(255,255,255,0.8);
    padding: 5px;
    border-radius: 4px;
}

/* Media queries */
@media (max-width: 991.98px) {
    .d-lg-table-cell {
        display: none;
    }
    .description-truncate {
        max-width: 180px;
    }
}

@media (max-width: 767.98px) {
    .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    .d-flex.gap-3 {
        flex-direction: column;
        gap: 1rem !important;
    }
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
    }
    .table-responsive {
        border-radius: 0.5rem;
        overflow: hidden;
        border: 1px solid #dee2e6;
    }
    .vehicle-icon {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    .vehicle-icon-lg,
    .cost-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    .description-truncate {
        max-width: 120px;
    }
    .accordion-button {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    .custom-badge {
        min-width: 24px;
        height: 24px;
        width: 24px;
        font-size: 0.8rem;
        margin-right: 8px;
    }
    .drag-handle {
        padding: 0 6px 0 8px;
    }
    .accordion-body {
        padding: 1rem;
    }
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    .card-text {
        font-size: 0.9rem;
    }
    .pagination .page-link {
        min-width: 44px;
        height: 44px;
        font-size: 16px;
    }
    .pagination .page-item:not(:nth-child(2)):not(:nth-last-child(2)):not(.d-md-block) {
        display: none;
    }
    .map-container {
        height: 300px;
    }
    .text-truncate {
        max-width: 65%;
    }
}

@media (max-width: 575.98px) {
    .mobile-date-wrap {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem !important;
    }
    .mobile-date-wrap .col-auto {
        width: 100% !important;
        margin-top: 0.25rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .mobile-date-wrap .text-muted.nowrap,
    .accordion-header .text-muted.nowrap {
        white-space: normal !important;
        display: flex !important;
        align-items: center;
        background-color: #f8f9fa;
        border-radius: 0.25rem;
        width: 100%;
        padding: 0.25rem 0.5rem;
        margin-top: 0.25rem;
    }
    .accordion-header .text-muted.nowrap i,
    .mobile-date-wrap .text-muted.nowrap i {
        margin-right: 0.5rem;
    }
    .accordion-header .row {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    .accordion-header .col,
    .accordion-header .col-auto:last-child {
        width: 100%;
        margin-top: 0.3rem;
        padding-left: 0;
    }
    .accordion-button {
        padding: 0.75rem 0.5rem !important;
    }
}
/* Stili generali */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Card personalizzate */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Form */
.form-control, .form-select {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
}

.form-control-lg, .form-select-lg {
    padding: 1rem 1.25rem;
}

/* Bottoni */
.btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    transform: translateY(-1px);
}

/* Navbar */
.navbar {
    padding: 0.75rem 0;
}

.nav-link {
    padding: 0.5rem 1rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 767.98px) {
    .navbar-brand img {
        height: 60px;
    }
    
    .content-wrapper {
        padding: 1.5rem;
    }
}