* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    -webkit-touch-callout: none;
    touch-action: pan-y;
}

/* Previene lo scroll orizzontale su mobile */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
    
    * {
        max-width: 100%;
    }
    
    /* Permette la selezione del testo nei campi input */
    input, textarea, select {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* Blocca lo scroll quando drawer o modale sono aperti */
body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 20px 30px;
    border-bottom: 2px solid #34495e;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8em;
    margin: 0 0 5px 0;
    font-weight: 600;
}

.header p {
    opacity: 0.85;
    font-size: 0.95em;
    margin: 0;
}

.schema-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

.schema-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.schema-link-mobile {
    color: #2c3e50;
    text-decoration: none;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid #e1e8ed;
}

.schema-link-mobile:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-btn span {
    width: 100%;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s;
}

/* Drawer mobile */
.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

.drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10001;
    transition: left 0.3s ease;
    overflow: hidden;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.drawer-open {
    left: 0 !important;
}

.drawer-header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}

.drawer-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.drawer-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.drawer-content {
    padding: 20px;
    padding-bottom: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 80px);
    min-height: 0;
    margin-bottom: 150px;
}

.drawer-content form {
    width: 100%;
    box-sizing: border-box;
}

.drawer-content .form-group {
    width: 100%;
    box-sizing: border-box;
}

.drawer-content .form-group input,
.drawer-content .form-group select {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-content .form-group select option {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-wrap: break-word;
    padding: 8px;
}

.content {
    padding: 20px;
    padding-top: 140px; /* Compensa l'altezza della toolbar fissa */
}

.results-table-container {
    overflow-x: auto;
    width: 100%;
}

.ricambio-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f9f9f9;
    padding: 2px;
}

.ricambio-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    padding: 5px;
}

.no-image {
    color: #999;
    font-size: 0.85em;
}

.form-section {
    background: #fafafa;
    padding: 18px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.form-section h2 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.3em;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.drawer .form-grid {
    grid-template-columns: 1fr;
    width: 100%;
    box-sizing: border-box;
}

/* Assicura che tutti gli autocomplete nel drawer mobile abbiano lo stesso styling */
.drawer .autocomplete-wrapper {
    width: 100%;
    box-sizing: border-box;
}

.drawer .autocomplete-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    padding: 12px 45px 12px 14px;
}

.text-input-group {
    grid-column: span 1;
}

.drawer .text-input-group {
    grid-template-columns: 1fr;
    display: grid;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Raggruppa i campi testuali riducendo il gap tra loro */
.text-input-group:not(:last-of-type) {
    margin-right: 0;
}

/* Results cards per mobile */
.results-cards {
    display: grid;
    gap: 28px;
    padding: 10px;
}

.result-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.card-image {
    width: 100%;
    padding: 20px;
    background: #f8f9fa;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.card-image img {
    max-width: 140px;
    max-height: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    margin: 0 auto;
}

.card-content {
    padding: 20px;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e9ecef;
}

.card-header strong {
    font-size: 1.2em;
    color: #2c3e50;
    font-weight: 700;
    line-height: 1.3;
}

.card-id {
    font-size: 0.85em;
    color: #6c757d;
    font-weight: 500;
}

.card-body {
    margin-bottom: 20px;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 12px;
}

.card-row:last-child {
    border-bottom: none;
}

.card-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
    min-width: 100px;
    flex-shrink: 0;
}

.card-row span:not(.card-label) {
    color: #212529;
    font-size: 0.95em;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

.card-price {
    font-weight: 700;
    color: #28a745;
    font-size: 1.15em;
}

.card-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
}

.card-actions .btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-sm {
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
}

/* Utility classes */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}


@media (min-width: 768px) {
    /* Riduce il gap solo tra i campi testuali */
    .text-input-group:nth-last-of-type(2) {
        margin-right: 6px;
    }
    
    .text-input-group:last-of-type {
        margin-left: 0;
    }
    
    /* Nascondi FAB button su desktop */
    .fab-button {
        display: none !important;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.95em;
    transition: border-color 0.2s;
    background: white;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c3e50' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.drawer .form-actions,
.drawer .button-group {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.drawer .form-actions .btn,
.drawer .button-group .btn {
    width: 100%;
    flex: none;
    min-width: auto;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-primary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

/* Filtri Attivi */
.active-filters-section {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.active-filters-header {
    margin-bottom: 12px;
}

.active-filters-header h3 {
    font-size: 1.1em;
    color: #2c3e50;
    margin: 0;
    font-weight: 600;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.filter-badge:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-label {
    font-weight: 600;
    opacity: 0.9;
}

.filter-value {
    font-weight: 500;
}

.filter-remove {
    margin-left: 4px;
    font-size: 1.2em;
    font-weight: bold;
    opacity: 0.8;
    line-height: 1;
}

.filter-remove:hover {
    opacity: 1;
}

.results-section {
    margin-top: 20px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.results-count {
    font-size: 1em;
    font-weight: 600;
    color: #2c3e50;
}

.search-version-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-v1 {
    background: #95a5a6;
    color: white;
}

.badge-v2 {
    background: #27ae60;
    color: white;
}

/* Descrizione versione ricerca */
.search-version-description {
    margin-top: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-left: 4px solid #3498db;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.search-version-description:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.search-version-description .description-text {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.7;
    color: #34495e;
    letter-spacing: 0.01em;
}

.search-version-description .description-text strong:first-child {
    color: #2c3e50;
    font-weight: 700;
    font-size: 1.05em;
    display: block;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    letter-spacing: -0.02em;
}

.search-version-description .description-text strong:not(:first-child) {
    color: #2c3e50;
    font-weight: 600;
    display: inline-block;
    margin-right: 4px;
    font-size: 0.95em;
}

.search-version-description .description-text br + strong {
    margin-top: 8px;
    display: block;
}

/* Colore bordo dinamico in base alla versione selezionata */
.form-group:has(select[id*="search_version"][value="v1"]) .search-version-description,
.form-group:has(select[id*="search_version"]:not([value="v2"])) .search-version-description {
    border-left-color: #7f8c8d;
    background: linear-gradient(135deg, #ffffff 0%, #f5f6f7 100%);
}

.form-group:has(select[id*="search_version"][value="v1"]) .search-version-description .description-text strong:first-child {
    color: #5a6c7d;
}

.form-group:has(select[id*="search_version"][value="v2"]) .search-version-description {
    border-left-color: #27ae60;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9f4 100%);
}

.form-group:has(select[id*="search_version"][value="v2"]) .search-version-description .description-text strong:first-child {
    color: #229954;
}

/* Nascondi la descrizione versione ricerca nel drawer mobile */
.drawer-content .search-version-description {
    display: none;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-size: 0.95em;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 3px;
    margin-bottom: 15px;
    border-left: 4px solid #dc3545;
    font-size: 0.9em;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #e0e0e0;
    font-size: 0.9em;
}

.results-table thead {
    background: #34495e;
    color: white;
}

.results-table th,
.results-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.results-table th {
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-table tbody tr:hover {
    background: #f8f9fa;
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.no-results {
    text-align: center;
    padding: 30px;
    color: #7f8c8d;
    font-size: 0.95em;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
}

.welcome-message {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 40px 30px;
    margin-top: 20px;
    text-align: center;
}

.welcome-content h2 {
    color: #2c3e50;
    font-size: 1.8em;
    margin: 0 0 20px 0;
    font-weight: 600;
    text-align: center;
}

.poc-notice {
    background: #e8f4f8;
    border-left: 4px solid #3498db;
    padding: 20px;
    margin: 0 0 30px 0;
    border-radius: 4px;
}

.poc-notice p {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 0.95em;
    line-height: 1.6;
}

.poc-notice p:first-child {
    font-weight: 600;
    font-size: 1em;
    margin-bottom: 12px;
}

.poc-notice p:last-child {
    margin-bottom: 0;
}

.welcome-content > p {
    color: #555;
    font-size: 1.1em;
    margin: 0 0 30px 0;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 30px;
    text-align: left;
}

.feature-item {
    background: white;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.feature-item strong {
    display: block;
    color: #2c3e50;
    font-size: 1.1em;
    margin-bottom: 10px;
    font-weight: 600;
}

.feature-item p {
    color: #666;
    font-size: 0.95em;
    margin: 0;
    line-height: 1.5;
}

.welcome-instructions {
    margin: 30px 0 0 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    border-left: 4px solid #27ae60;
}

.welcome-instructions p {
    margin: 0;
    color: #2c3e50;
    font-size: 0.95em;
    line-height: 1.6;
}

.welcome-instructions strong {
    color: #27ae60;
    font-weight: 600;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #3498db;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    color: #2c3e50;
    font-weight: 600;
    font-size: 0.9em;
    padding: 0 10px;
}

.btn-detail {
    background: #3498db;
    border: none;
    border-radius: 3px;
    padding: 6px 10px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-detail:hover:not(:disabled) {
    background: #2980b9;
}

.btn-detail:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Modale */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 4px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px 4px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.2s;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.detail-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-section h4 {
    color: #2c3e50;
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9em;
}

.detail-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-item {
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #2c3e50;
}

.detail-empty {
    color: #7f8c8d;
    font-style: italic;
    font-size: 0.9em;
}

.annate-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Accordion per annate raggruppate per anno */
.annate-accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.year-accordion-item {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.year-accordion-item:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-color: #bdc3c7;
}

.year-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    background: #f8f9fa;
    transition: all 0.3s ease;
    user-select: none;
}

.year-accordion-header:hover {
    background: #e9ecef;
}

.year-accordion-header.expanded {
    background: #e3f2fd;
    border-bottom: 1px solid #e0e0e0;
}

.year-header-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.year-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05em;
    color: #2c3e50;
}

.year-title strong {
    font-weight: 600;
}

.year-count {
    color: #7f8c8d;
    font-size: 0.9em;
    font-weight: normal;
}

.year-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85em;
}

.summary-item {
    color: #34495e;
}

.summary-item strong {
    color: #2c3e50;
    margin-right: 4px;
}

.year-accordion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7f8c8d;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.year-accordion-header.expanded .year-accordion-icon {
    transform: rotate(180deg);
}

.year-accordion-content {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
}

.year-accordion-content .annata-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.year-accordion-content .annata-item:last-child {
    margin-bottom: 0;
}

.year-accordion-content .annata-header {
    margin-bottom: 8px;
}

.year-accordion-content .annata-info {
    color: #34495e;
    font-size: 0.9em;
}

.year-accordion-content .annata-info strong {
    color: #2c3e50;
    margin-right: 4px;
}

/* Telaio Accordion (secondo livello) */
.telaio-accordion-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.telaio-accordion-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.telaio-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f1f3f5;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.telaio-accordion-header:hover {
    background: #e9ecef;
}

.telaio-accordion-header.expanded {
    background: #d3e5ff;
    border-bottom: 1px solid #dee2e6;
}

.telaio-header-content {
    flex: 1;
}

.telaio-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    color: #2c3e50;
}

.telaio-count {
    font-size: 0.85em;
    color: #6c757d;
    font-weight: normal;
    margin-left: 8px;
}

.telaio-accordion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: #6c757d;
}

.telaio-accordion-header.expanded .telaio-accordion-icon {
    transform: rotate(180deg);
}

.telaio-accordion-content {
    padding: 12px 16px;
    background: #ffffff;
}

/* Modello Accordion (terzo livello) */
.modello-accordion-item {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.modello-accordion-item:last-child {
    margin-bottom: 0;
}

.modello-accordion-item:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.modello-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.modello-accordion-header:hover {
    background: #f0f0f0;
}

.modello-accordion-header.expanded {
    background: #fff3cd;
    border-bottom: 1px solid #e0e0e0;
}

.modello-header-content {
    flex: 1;
}

.modello-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #34495e;
    flex-wrap: wrap;
}

.modello-tipo {
    font-size: 0.85em;
    color: #7f8c8d;
    font-weight: normal;
    font-style: italic;
}

.modello-count {
    font-size: 0.8em;
    color: #6c757d;
    font-weight: normal;
    margin-left: 6px;
}

.modello-accordion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: #6c757d;
}

.modello-accordion-header.expanded .modello-accordion-icon {
    transform: rotate(180deg);
}

.modello-accordion-content {
    padding: 10px 14px;
    background: #ffffff;
}

.modello-accordion-content .annata-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 8px;
}

.modello-accordion-content .annata-item:last-child {
    margin-bottom: 0;
}

/* Stili per annata model info */
.annata-model-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.annata-model-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.annata-label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 70px;
}

.annata-value {
    color: #34495e;
}

/* Stili per seriali group header */
.seriali-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.seriali-group-icon {
    font-size: 1.1em;
}

.seriali-empty-icon {
    margin-right: 6px;
}

.detail-empty-icon {
    margin-right: 6px;
}

.annata-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 12px;
}

.annata-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.annata-header strong {
    color: #2c3e50;
    font-size: 0.95em;
}

.annata-info {
    color: #7f8c8d;
    font-size: 0.85em;
}

.seriali-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.seriali-group {
    margin-bottom: 6px;
    font-size: 0.9em;
}

.seriali-group strong {
    color: #2c3e50;
    margin-right: 8px;
}

.seriali-group span {
    color: #34495e;
}

/* Nuova sezione Seriali - Design moderno */
.seriali-list {
    margin-top: 12px;
}

.seriali-type-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.seriali-type-section {
    background: #f8f9fa;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s ease;
}

.seriali-type-section:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: #bdc3c7;
}

.seriali-type-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px 0;
    font-size: 0.95em;
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.seriali-icon {
    font-size: 1.2em;
}

.seriali-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.seriale-badge {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.seriale-badge.seriale-dalpoi {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: 1px solid #2980b9;
}

.seriale-badge.seriale-dalpoi:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.seriale-badge.seriale-finoal {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: 1px solid #c0392b;
}

.seriale-badge.seriale-finoal:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.seriali-inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 8px;
}

.seriale-inline {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    margin-right: 4px;
}

.seriale-inline.seriale-dalpoi {
    background: rgba(52, 152, 219, 0.15);
    color: #2980b9;
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.seriale-inline.seriale-finoal {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.seriali-empty {
    color: #95a5a6;
    font-style: italic;
    font-size: 0.9em;
    padding: 8px 0;
}

/* Media queries per mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    /* FAB Button visibile solo su mobile */
    .fab-button.mobile-only {
        display: flex !important;
    }
    
    .fab-button.mobile-only:not(.hidden) {
        z-index: 10000 !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .drawer-overlay {
        display: block !important;
    }
    
    .drawer {
        display: block !important;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.4em;
    }
    
    .header p {
        font-size: 0.85em;
    }
    
    .content {
        padding: 15px;
        padding-top: 120px; /* Compensa l'altezza della toolbar fissa su mobile */
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .text-input-group {
        grid-template-columns: 1fr;
    }
    
    .results-table {
        font-size: 0.85em;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 4px;
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
        max-height: 90vh;
    }
    
    .ricambio-image {
        max-width: 100%;
        max-height: 200px;
    }
    
    .detail-section > div[style*="display: flex"] {
        flex-direction: column !important;
    }
    
    .detail-section > div[style*="display: flex"] > div:first-child {
        margin-bottom: 15px;
        text-align: center;
    }
    
    /* Assicura che le select nel drawer mobile siano contenute */
    .drawer-content .form-group select {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .drawer-content .form-group select option {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2em;
    }
    
    .drawer {
        width: 100%;
        max-width: 100%;
    }
    
    /* Assicura che le select siano contenute anche su schermi molto piccoli */
    .drawer-content .form-group select {
        font-size: 0.9em;
    }
    
    .drawer-content .form-group select option {
        font-size: 0.9em;
        padding: 10px 8px;
    }
    
    .results-cards {
        gap: 24px;
        padding: 12px;
    }
    
    .result-card {
        margin-bottom: 0;
        border-radius: 10px;
    }
    
    .card-image {
        padding: 24px 20px;
    }
    
    .card-image img {
        max-width: 120px;
        max-height: 120px;
        width: auto;
        height: auto;
        object-fit: contain;
    }
    
    .card-content {
        padding: 20px 16px;
    }
    
    .card-header {
        margin-bottom: 18px;
        padding-bottom: 18px;
    }
    
    .card-header strong {
        font-size: 1.15em;
    }
    
    .card-body {
        margin-bottom: 18px;
    }
    
    .card-row {
        padding: 10px 0;
    }
    
    .card-actions {
        margin-top: 18px;
        padding-top: 18px;
    }
    
    .welcome-message {
        padding: 25px 20px;
    }
    
    .welcome-content h2 {
        font-size: 1.4em;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .feature-item {
        padding: 15px;
    }
}

/* FAB Button per mobile */
.fab-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: none; /* Nascosto di default - verrà mostrato su mobile */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 1;
    visibility: visible;
    padding: 0;
}

.fab-button:hover {
    background: #2980b9;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fab-button:active {
    transform: scale(0.95);
}

.fab-button.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.fab-button svg {
    width: 24px;
    height: 24px;
}

/* Autocomplete Styles - Design Moderno e Professionale */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-input {
    width: 100%;
    padding: 12px 45px 12px 14px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.autocomplete-input::placeholder {
    color: #95a5a6;
    font-style: normal;
}

.autocomplete-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #ffffff;
}

.autocomplete-input:hover:not(:focus) {
    border-color: #bdc3c7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 2px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar personalizzata per il dropdown */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f4f8;
    color: #2c3e50;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.autocomplete-item:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.autocomplete-item:hover {
    background: linear-gradient(90deg, #f8f9fa 0%, #f1f3f5 100%);
    color: #2c3e50;
    padding-left: 20px;
}

.autocomplete-item.highlighted {
    background: linear-gradient(90deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1976d2;
    font-weight: 500;
    padding-left: 20px;
    border-left: 3px solid #3498db;
}

.autocomplete-item.selected {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
    color: #1b5e20;
    font-weight: 600;
    border-left: 4px solid #27ae60;
    box-shadow: inset 0 0 0 1px rgba(39, 174, 96, 0.1);
    position: relative;
    padding-left: 40px;
}

.autocomplete-item.selected::before {
    content: '✓';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #27ae60;
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.9);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.2);
}

.autocomplete-item.selected.highlighted {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 50%, #81c784 100%);
    border-left-color: #27ae60;
    box-shadow: inset 0 0 0 1px rgba(39, 174, 96, 0.15), 0 2px 4px rgba(39, 174, 96, 0.1);
}

.autocomplete-no-results {
    padding: 20px 16px;
    color: #7f8c8d;
    font-style: italic;
    text-align: center;
    font-size: 14px;
    background: #fafbfc;
}

/* Per i select trasformati in autocomplete */
.autocomplete-select-wrapper {
    position: relative;
}

.autocomplete-select-wrapper .autocomplete-input {
    cursor: pointer;
    padding-right: 50px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
}

.autocomplete-select-wrapper .autocomplete-input:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233498db' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.autocomplete-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #95a5a6;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.autocomplete-clear-btn:hover {
    color: #ffffff;
    background: #e74c3c;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.autocomplete-clear-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.autocomplete-clear-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

/* Stili per il selettore di raggruppamento */
.group-by-selector {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.group-by-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9em;
}

.group-by-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.group-by-btn {
    padding: 8px 16px;
    border: 2px solid #3498db;
    background: #ffffff;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.group-by-btn:hover {
    background: #e8f4f8;
    border-color: #2980b9;
    color: #2980b9;
}

.group-by-btn.active {
    background: #3498db;
    color: #ffffff;
    border-color: #3498db;
}

.group-by-btn.active:hover {
    background: #2980b9;
    border-color: #2980b9;
}

/* Stili per le combo items */
.combo-item {
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #3498db;
    border-radius: 4px;
}

.combo-header {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.combo-header strong {
    color: #34495e;
}

.combo-sub-item {
    margin-top: 8px;
    padding-left: 12px;
    border-left: 2px solid #95a5a6;
}

.combo-sub-header {
    font-weight: 500;
    color: #34495e;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.combo-sub-header strong {
    color: #2c3e50;
}


