:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f1f5f9;
    --text: #334155;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg);
    margin: 0;
    color: var(--text);
}

.container { max-width: 1100px; margin: 0 auto; padding: 40px 20px; }

/* Navbar */
nav {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    margin-left: 20px;
    font-weight: 500;
}

.nav-links a.active { color: var(--primary); }

.btn-logout {
    color: #ef4444 !important;
    border: 1px solid #ef4444;
    padding: 5px 15px;
    border-radius: 4px;
}

/* Dashboard Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    text-align: center;
}

.icon { font-size: 40px; margin-bottom: 15px; }

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary { background: var(--primary); color: white; border: none; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-disabled { background: #cbd5e1; color: white; cursor: not-allowed; }

.hero { text-align: center; }
.hero h1 { font-size: 2.5rem; margin-bottom: 10px; color: #0f172a; }

/* ... (mantieni le regole precedenti per navbar, card e bottoni) ... */

/* Stili specifici per i Form */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    max-width: 800px;
    margin: 20px auto;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #475569;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box; /* Assicura che il padding non sballi la larghezza */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Griglia per input affiancati */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Opzioni Radio e Checkbox */
.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 15px;
    border-radius: 6px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Responsive per il form */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ... (regole precedenti) ... */

/* Pagina Risultato AI */
.result-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    overflow: hidden;
    margin-top: 20px;
}

.result-header {
    background: #f1f5f9;
    padding: 20px 30px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-content-area {
    padding: 40px;
    line-height: 1.8;
    color: #334155;
    font-size: 1.1rem;
    white-space: pre-line; /* Mantiene gli a capo del testo generato */
}

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.loading-overlay {
    text-align: center;
    padding: 50px;
}

/* Animazione semplice per il caricamento */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* ... (mantieni le regole precedenti per navbar, card e form) ... */

/* Stili per la pagina Storico */
.filters-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    overflow-x: auto; /* Fondamentale per il responsive su mobile */
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    text-transform: uppercase;
    padding: 15px 20px;
    border-bottom: 2px solid #e2e8f0;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.95rem;
}

tr:hover {
    background-color: #fbfcfe;
}

/* Esito Badges */
.status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-success { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }

/* Responsive Filtri */
@media (max-width: 768px) {
    .filters-container { flex-direction: column; align-items: stretch; }
}