/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
   display: block; /* Cambiato da flex a block */
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.container {
    width: 100%;
    max-width: 480px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    margin: 0 auto; /* Centra orizzontalmente */
    animation: slideUp 0.5s ease;
    /* RIMOSSO overflow: hidden che potrebbe tagliare il contenuto */
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.logo {
    width: 80px;
    height: 80px;
    background: white;
    /*border-radius: 50%;*/
    padding: 5px;
    margin: 0 auto 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.header h1 {
    font-size: 28px;
    margin-bottom: 5px;
    font-weight: 700;
}

.header p {
    opacity: 0.9;
    font-size: 16px;
}

/* Form */
.form-container {
    padding: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e1e1;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Bottoni */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e1e1;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* Dashboard */
.dashboard {
    padding: 20px;
}

.welcome {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.welcome h2 {
    color: #333;
    margin-bottom: 5px;
}

.welcome p {
    color: #666;
    font-size: 14px;
}

/* Card scadenze */
.scadenze-container {
    margin-bottom: 30px;
}

.scadenza-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 5px solid #667eea;
}

.scadenza-card.scaduta {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.scadenza-card.in-scadenza {
    border-left-color: #ffc107;
    background: #fff9e6;
}

.scadenza-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.scadenza-titolo {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.scadenza-stato {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.scadenza-stato.valido {
    background: #d4edda;
    color: #155724;
}

.scadenza-stato.scaduto {
    background: #f8d7da;
    color: #721c24;
}

.scadenza-stato.in-scadenza {
    background: #fff3cd;
    color: #856404;
}

.scadenza-data {
    color: #666;
    font-size: 14px;
}

.scadenza-giorni {
    margin-top: 5px;
    font-size: 13px;
    color: #999;
}

/* QR Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#qr-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#qr-timer {
    margin-top: 15px;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
}

#qr-timer.scaduto {
    color: #dc3545;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
}

/* Loading spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Messaggi */
.alert {
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Footer PWA */
.install-prompt {
    margin-top: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    border: 2px dashed #dee2e6;
}

.install-prompt p {
    margin-bottom: 10px;
    color: #666;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        border-radius: 0;
        margin: 0;
        height: 100vh;
        max-width: none;
    }
    
    .header {
        padding: 20px;
    }
    
    .form-container {
        padding: 20px;
    }
}

/* Animazioni */
.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Install prompt animations */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-prompt {
    animation: slideInUp 0.3s ease;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 1000;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: none;
}

.install-prompt.show {
    display: block;
}

/* Badge per nuovo contenuto */
.update-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Install steps */
.install-steps {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.install-step {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 15px;
    border-left: 4px solid #667eea;
}

.install-step h4 {
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.install-step ol {
    margin-left: 20px;
    color: #555;
}

.install-step li {
    margin-bottom: 8px;
}

/* Platform icons */
.fab, .fas {
    color: #667eea;
}

/* Offline notification */
.offline-notification {
    position: fixed;
    bottom: 80px;
    left: 20px;
    right: 20px;
    z-index: 999;
    animation: slideInUp 0.3s ease;
}

/* Update available */
.update-available {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 1001;
    animation: slideInUp 0.3s ease;
}

/* Stili per le scadenze */
.scadenze-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.scadenza-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 5px solid #667eea;
    transition: transform 0.3s;
}

.scadenza-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.scadenza-card.scaduto {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, #fff5f5 0%, #ffeaea 100%);
}

.scadenza-card.in-scadenza {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
}

.scadenza-card.valido {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #f0fff4 0%, #e6ffe6 100%);
}

.scadenza-card.sconosciuto {
    border-left-color: #6c757d;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.scadenza-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.scadenza-titolo {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.scadenza-stato {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.scadenza-stato.valido {
    background: #d4edda;
    color: #155724;
}

.scadenza-stato.scaduto {
    background: #f8d7da;
    color: #721c24;
}

.scadenza-stato.in-scadenza {
    background: #fff3cd;
    color: #856404;
}

.scadenza-stato.sconosciuto {
    background: #e2e3e5;
    color: #383d41;
}

.scadenza-data {
    color: #666;
    font-size: 15px;
    margin-bottom: 5px;
}

.scadenza-giorni {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

.no-scadenze {
    text-align: center;
    padding: 30px;
    color: #666;
    font-style: italic;
}

.ultimi-accessi-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ultimi-accessi-list li {
    padding: 8px 15px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

/* Pulsante genera QR */
#btn-genera-qr {
    width: 100%;
    padding: 15px;
    margin: 20px 0;
    font-size: 16px;
}

/* Aggiungi a /css/styles.css */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: auto !important; /* Forza scroll */
    -webkit-overflow-scrolling: touch; /* Scroll fluido su iOS */
}

.container {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    padding-bottom: 20px;
}

#dashboard-container {
    height: auto;
    min-height: 100%;
    overflow-y: visible;
    padding: 20px;
    padding-bottom: 80px; /* Spazio per pulsanti in fondo */
}

.scadenze-list {
    max-height: none !important; /* Rimuovi limiti di altezza */
    overflow: visible;
}

/* Fix per modal su mobile */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
}

/* Aggiungi al tuo CSS */
#btn-genera-qr:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #999 0%, #666 100%);
    pointer-events: none;
}

#btn-genera-qr:disabled:hover {
    transform: none;
    box-shadow: none;
}

#msg-scadenza {
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* Stili per rinnovi */
.rinnovo-container {
    margin: 20px 0;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
}

.rinnovo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.rinnovo-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e1e1e1;
    transition: transform 0.3s;
}

.rinnovo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.rinnovo-card h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
}

.rinnovo-card .descrizione {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    min-height: 40px;
}

.rinnovo-card .dettagli {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #555;
}

.rinnovo-card .dettagli span {
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 5px;
}

.rinnovo-card .prezzo {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin: 15px 0;
    text-align: center;
}

.rinnovo-card .btn-sm {
    padding: 10px;
    font-size: 14px;
}