/* Titolo principale */
.config-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: #333;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.config-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #3f51b5);
    border-radius: 4px;
}

/* Tabs e navigazione - Material Design */
.config-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing-md);
    padding: 10px;
    position: relative;
    z-index: 1;
    background-color: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.config-tabs::-webkit-scrollbar {
    height: 5px; /* Altezza della scrollbar */
}

.config-tabs::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 10px;
}

.config-tabs::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--primary-color), #3f51b5);
    border-radius: 10px;
    border: 2px solid #f5f5f5;
}

.config-tabs::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #3f51b5, var(--primary-color));
}

/* Indicatore visivo che ci sono più tab */
.config-tabs::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 5px; /* Lascia spazio per la scrollbar */
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
    pointer-events: none;
}

.config-tab {
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 500;
    color: var(--medium-text);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-decoration: none;
    text-align: center;
    min-width: 120px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background-color: #f8f9fa;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 85px;
    flex: 0 0 calc(25% - 10px); /* 4 tab per riga con gap di 10px */
    max-width: calc(25% - 10px);
    font-size: 0.95rem;
    margin: 0 5px 10px 0;
}

.config-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.config-tab:hover {
    color: var(--primary-color);
    background-color: #ffffff;
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.config-tab:hover::before {
    opacity: 1;
}

.config-tab.active {
    color: white;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), #3f51b5);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.25);
    border-color: transparent;
    transform: translateY(-5px);
}

.config-tab.active::before {
    opacity: 1;
}

/* Aggiungiamo icone ai tab */
.config-tab::after {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.config-tab[data-target="prodotti-tab"]::after {
    content: '\f07a'; /* fa-shopping-cart */
}

.config-tab[data-target="ingredienti-tab"]::after {
    content: '\f5d1'; /* fa-apple-alt */
}

.config-tab[data-target="ricette-tab"]::after {
    content: '\f2e7'; /* fa-utensils */
}

.config-tab[data-target="allergeni-tab"]::after {
    content: '\f06e'; /* fa-eye */
}

.config-tab[data-target="calorie-tab"]::after {
    content: '\f5cd'; /* fa-weight */
}

.config-tab[data-target="scarica-tab"]::after {
    content: '\f019'; /* fa-download */
}

.config-tab[data-target="telegram-tab"]::after {
    content: '\f1d8'; /* fa-paper-plane */
}

.config-tab[data-target="tools-tab"]::after {
    content: '\f7d9'; /* fa-tools */
}

.config-content {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    background-color: var(--white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    transition: all 0.4s ease;
    position: relative;
}

.config-content.active {
    display: block;
}

.config-content h2 {
    font-size: 1.8rem;
    margin-bottom: var(--spacing-lg);
    color: #333;
    position: relative;
    padding-bottom: 15px;
    text-align: center;
}

.config-content h2:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #3f51b5);
    border-radius: 4px;
}

/* Elementi della configurazione - Material Design */
.product-list {
    margin-bottom: var(--spacing-xl);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

.product-item {
    padding: 16px 20px;
    background-color: var(--white);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.product-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-item:hover {
    background-color: var(--primary-light);
    transform: translateX(5px) translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    z-index: 1;
}

.product-item:hover::after {
    opacity: 1;
}

.product-item:last-child {
    border-bottom: none;
}

.product-name {
    font-weight: 500;
    flex-grow: 1;
    color: var(--dark-text);
    transition: color 0.3s ease;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.4;
}

.product-item:hover .product-name {
    color: var(--primary-color);
}

.product-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    z-index: 2;
    position: relative;
}

.product-item.preselezionato {
    background-color: var(--success-light);
    border-left: 4px solid var(--success-color);
}

.product-item.preselezionato::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent var(--success-color) transparent transparent;
}

.product-item.selected {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-left: 4px solid var(--primary-color);
    font-weight: 600;
}

/* Stile per i menu a tendina e campi di input */
select, input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="url"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--white);
    border: 2px solid #e9ecef;
    border-radius: 50px;
    padding: 15px 20px;
    font-size: 1.05rem;
    font-family: 'Poppins', sans-serif;
    color: var(--dark-text);
    width: 100%;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin-bottom: var(--spacing-md);
    height: 56px;
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f5d75' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 16px;
    padding-right: 50px;
}

select:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, 
input[type="password"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="url"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 6px 18px rgba(67, 97, 238, 0.15);
    transform: translateY(-2px);
}

select:hover, input[type="text"]:hover, input[type="number"]:hover, input[type="email"]:hover,
input[type="password"]:hover, input[type="search"]:hover, input[type="tel"]:hover, input[type="url"]:hover {
    border-color: #d8e0fd;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

select option {
    padding: 12px;
    font-size: 1rem;
}

input::placeholder {
    color: var(--medium-text);
    opacity: 0.7;
}

.form-container {
    margin-bottom: var(--spacing-lg);
}

.add-product-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    align-items: flex-start;
    margin-bottom: var(--spacing-lg);
}

.form-row {
    flex: 1;
    min-width: 200px;
}

.form-row:last-child {
    flex: 0 0 auto;
    min-width: auto;
    display: flex;
    align-items: center;
}

.add-product-form select,
.add-product-form input[type="text"] {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 992px) {
    .config-tab {
        flex: 0 0 calc(33.33% - 15px);
        max-width: calc(33.33% - 15px);
        font-size: 0.9rem;
        padding: 10px;
        height: 85px;
    }
}

@media (max-width: 768px) {
    .config-tab {
        flex: 0 0 calc(50% - 10px);
        max-width: calc(50% - 10px);
        padding: 10px;
        font-size: 0.85rem;
        height: 80px;
        margin-right: 5px;
        margin-bottom: 10px;
    }
    
    .config-tab::after {
        font-size: 20px;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .config-tab {
        flex: 0 0 calc(50% - 8px) !important;
        max-width: calc(50% - 8px) !important;
        height: 65px;
        padding: 6px;
        margin-right: 4px;
        margin-bottom: 8px;
        min-width: 0 !important;
        width: calc(50% - 8px) !important;
        font-size: 0.8rem !important;
    }
    
    .config-tab::after {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .config-tabs {
        padding: 5px;
        gap: 8px;
        justify-content: space-between;
        display: flex !important;
        flex-wrap: wrap !important;
    }
    
    .tabs-container {
        padding: 8px 5px !important;
    }
    
    /* Forza 2 tab per riga */
    .config-tab:nth-child(odd) {
        margin-right: 8px !important;
    }
    
    .config-tab:nth-child(even) {
        margin-right: 0 !important;
    }
}

/* Regole specifiche per schermi molto piccoli */
@media (max-width: 430px) {
    .config-tab {
        height: 60px !important;
        padding: 5px !important;
        font-size: 0.75rem !important;
    }
    
    .config-tab::after {
        font-size: 14px !important;
        margin-bottom: 1px !important;
    }
    
    .config-tabs {
        gap: 6px !important;
    }
}
    
    .product-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .product-name {
        margin-bottom: var(--spacing-sm);
    }
    
    .product-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    select, input[type="text"], input[type="number"], input[type="email"], 
    input[type="password"], input[type="search"], input[type="tel"], input[type="url"] {
        font-size: 16px; /* Evita lo zoom su iOS */
        height: 56px; /* Più facile da toccare su mobile */
    }
    
    .add-product-form {
        flex-direction: column;
    }
    
    .form-row {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }
    
    .form-row:last-child {
        margin-bottom: 0;
        justify-content: center;
    }
    
    .add-product-form select,
    .add-product-form input[type="text"] {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }
    
    .btn-icon-only {
        width: 56px !important;
        height: 56px !important;
    }
}

/* Stili per i tab Telegram e Tools */
#telegram-tab, #tools-tab {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Stili per i contenitori dei tab */
.tools-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.tool-card {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tool-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.tool-card p {
    margin-bottom: 15px;
    line-height: 1.5;
}

.script-list {
    margin-top: 20px;
}

.script-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 6px;
    border-left: 4px solid #ddd;
    margin-bottom: 10px;
}

.script-info {
    flex: 1;
}

.script-info h4 {
    margin-top: 0;
    margin-bottom: 5px;
    color: #333;
}

.script-info p {
    margin: 5px 0;
    color: #555;
}

.script-path {
    font-family: monospace;
    font-size: 0.9em;
    color: #666;
}

.script-actions {
    margin-left: 15px;
}

.tool-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.tool-results {
    margin-top: 20px;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 6px;
}

.script-output {
    margin-top: 20px;
}

.tab-title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    width: 100%;
    position: relative;
}

#telegram-tab h2, #tools-tab h2 {
    margin-bottom: 0;
}

.info-icon {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-style: italic;
    font-weight: bold;
    font-size: 14px;
}

/* Stili per il tab Telegram */
.radio-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-input {
    margin-right: 5px;
    width: 20px;
    height: 20px;
}

.radio-text.active {
    color: #28a745;
    font-weight: 500;
    font-size: 16px;
}

.radio-text.inactive {
    color: #dc3545;
    font-weight: 500;
    font-size: 16px;
}

.form-label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 16px;
}

.contatto-item {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 15px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary-color);
}

.contatto-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.contatto-item .form-group {
    width: 100%;
}

.btn-sm {
    width: 40px;
    height: 40px;
}

/* Stili aggiuntivi per i tab Tools */
.tool-results {
    margin-top: 20px;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.tool-results h4 {
    margin-top: 0;
    color: var(--primary-color);
}

.tool-results ul {
    margin-bottom: 0;
}

.script-output {
    margin-top: 20px;
}

.output-frame {
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    font-family: monospace;
    white-space: pre-wrap;
}

/* Stili per l'editor di script */
.script-editor {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

textarea.form-control {
    resize: vertical;
    font-family: monospace;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    border: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.results-table th, .results-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.results-table th {
    background-color: #f2f2f2;
    font-weight: 600;
}

@media (max-width: 600px) {
    .config-tabs {
        flex-wrap: wrap;
    }
    
    .config-tab {
        flex-basis: 50%;
        min-width: 0;
        font-size: 0.85rem;
        padding: var(--spacing-sm) var(--spacing-sm);
    }
}

/* Animazioni */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Effetto ripple per i pulsanti */
@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(30, 30);
        opacity: 0;
    }
}