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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    padding: 40px;
}

.form-section {
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 1.1em;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(102, 126, 234, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.results {
    display: none;
    margin-top: 40px;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

.results-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.results-title {
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 20px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.numbers-list {
    display: grid;
    gap: 12px;
}

.number-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.number-item:hover {
    transform: translateX(5px);
}

.number-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    margin-right: 15px;
    flex-shrink: 0;
}

.number-meaning {
    font-weight: 500;
    color: #2c3e50;
}

.interpretation {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    font-size: 1.05em;
    line-height: 1.7;
    color: #495057;
}

/* <!-- NUOVO: Stile per l'evidenziazione --> */
mark {
    background-color: #d1d8ff;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
    color: #2c3e50;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    margin-top: 20px;
}

.example {
    background: #e7f3ff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border-left: 4px solid #667eea;
}

.example h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.example-text {
    font-style: italic;
    color: #495057;
    margin-bottom: 10px;
}

.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-top: 1px solid #e9ecef;
    margin-top: 20px;
    font-size: 0.9em;
    color: #6c757d;
}

.icon {
    font-size: 1.2em;
}
/* Stile per il pulsante secondario (Cronologia) */
.btn-secondary {
    background: #6c757d; /* Un grigio neutro */
    
}

.btn-secondary:hover {
    background: #5a6268;
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.15);
}


/* Stili per la Finestra Modale della Cronologia */
.modal {
    display: none; /* Nascosto di default */
    position: fixed; /* Rimane fisso durante lo scroll */
    z-index: 1000; /* Sta sopra a tutto */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Abilita lo scroll se il contenuto è troppo lungo */
    background-color: rgba(0, 0, 0, 0.6); /* Sfondo semi-trasparente */
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.4s ease-in-out;
}

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


.close-btn {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
}

.history-list {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: #f8f9fa;
    border-left: 4px solid #764ba2;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.history-item h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-style: italic;
}

.history-item p {
    font-size: 0.95em;
    color: #495057;
    margin-bottom: 10px;
}

.history-item small {
    font-weight: bold;
    color: #667eea;
}
/* Stili per i Pulsanti di Azione (Copia/Condividi) */
.action-buttons {
    display: none; /* Nascosti di default, li mostriamo con JS */
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 15px; /* Spazio tra i pulsanti */
    flex-wrap: wrap; /* Vanno a capo su schermi piccoli */
}

.action-btn {
    background-color: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

/* Stile per il pulsante quando la copia è avvenuta */
.action-btn.copied {
    background-color: #d4edda; /* Verde successo */
    color: #155724;
    border-color: #c3e6cb;
}
/* Stili per il pulsante di eliminazione nella cronologia */
.history-item {
    position: relative; /* Necessario per posizionare il pulsante di eliminazione */
}

.history-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #f8d7da; /* Rosso chiaro per indicare eliminazione */
    color: #721c24;
    border: 1px solid #f5c6cb;
    width: 28px;
    height: 28px;
    border-radius: 50%; /* Lo rende rotondo */
    font-size: 18px;
    font-weight: bold;
    line-height: 26px; /* Centra la 'x' verticalmente */
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-delete-btn:hover {
    background-color: #e0717b;
    color: white;
    transform: scale(1.1);
}
/* Stili per l'interruttore (toggle) dell'IA */
.ai-toggle-container {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #495057;
}

.ai-toggle-checkbox {
    opacity: 0; /* Nascondiamo la checkbox originale */
    width: 0;
    height: 0;
}

.ai-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    background-color: #ccc;
    border-radius: 28px;
    transition: background-color 0.3s;
    margin-right: 12px;
}

.ai-toggle-switch::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: white;
    top: 4px;
    left: 4px;
    transition: transform 0.3s;
}

/* Stile per quando l'interruttore è ATTIVO (checked) */
.ai-toggle-checkbox:checked + .ai-toggle-switch {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-toggle-checkbox:checked + .ai-toggle-switch::before {
    transform: translateX(22px);
}

.ai-toggle-text {
    user-select: none; /* Impedisce la selezione del testo al click */
}
/* NUOVO: Stili per il contenitore dei pulsanti del form */
.form-actions-container {
    display: flex;         /* Attiva Flexbox: il modo moderno per allineare elementi */
    align-items: center;   /* Allinea verticalmente i pulsanti al centro (risolve disallineamenti di altezza) */
    gap: 15px;             /* Crea uno spazio di 15px tra i pulsanti */
    flex-wrap: wrap;       /* Molto importante: se lo spazio non basta (su mobile), manda i pulsanti a capo */
}
