/* ============================================================
   BADGE DIGITALE - Safety Smart
   CSS Mobile-First Responsive
   ============================================================ */

/* --- RESET E BASE --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- CONTAINER --- */
.badge-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    box-shadow: 0 0 30px rgba(0,0,0,0.08);
}

/* --- HEADER --- */
.badge-header {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 50%, #43A047 100%);
    padding: 20px 20px 25px;
    text-align: center;
    position: relative;
}

.badge-header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 5px;
}

.badge-header-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #2E7D32;
    font-size: 18px;
}

.badge-header-logo h1 {
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-header-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    margin-top: 2px;
}

/* --- FOTO PROFILO --- */
.badge-photo-wrapper {
    text-align: center;
    margin-top: -40px;
    position: relative;
    z-index: 2;
}

.badge-photo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    object-fit: cover;
    background: #e0e0e0;
}

.badge-photo-placeholder {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #43A047, #2E7D32);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 36px;
    font-weight: 600;
}

/* --- INFO LAVORATORE --- */
.badge-info-worker {
    text-align: center;
    padding: 12px 20px 5px;
}

.badge-info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
    margin-bottom: 4px;
}

.badge-info-name {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.badge-info-detail {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

/* --- SEZIONE CONTENUTO --- */
.badge-content {
    padding: 20px;
}

/* --- CARD GENERICA --- */
.badge-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    padding: 24px;
    margin-bottom: 16px;
}

.badge-card-elevated {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* --- FORM OTP --- */
.otp-section {
    text-align: center;
    padding: 30px 20px;
}

.otp-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.otp-icon svg {
    width: 32px;
    height: 32px;
    color: #2E7D32;
}

.otp-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.otp-subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
    line-height: 1.5;
}

.otp-inputs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.otp-inputs input {
    width: 48px;
    height: 56px;
    border: 2px solid #ddd;
    border-radius: 10px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.otp-inputs input:focus {
    border-color: #2E7D32;
    box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
}

.otp-inputs input::-webkit-inner-spin-button,
.otp-inputs input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- PULSANTI --- */
.btn-badge {
    display: inline-block;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
}

.btn-badge-primary {
    background: linear-gradient(135deg, #2E7D32, #43A047);
    color: #fff;
}

.btn-badge-primary:hover {
    background: linear-gradient(135deg, #1B5E20, #2E7D32);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46,125,50,0.3);
}

.btn-badge-primary:active {
    transform: translateY(0);
}

.btn-badge-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-badge-secondary {
    background: transparent;
    color: #2E7D32;
    border: 2px solid #2E7D32;
}

.btn-badge-secondary:hover {
    background: #E8F5E9;
}

.btn-badge-gold {
    background: linear-gradient(135deg, #F9A825, #FBC02D);
    color: #333;
}

.btn-badge-gold:hover {
    background: linear-gradient(135deg, #F57F17, #F9A825);
}

/* --- STATO DOCUMENTALE --- */
.stato-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    margin: 10px 0;
}

.stato-ok {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #A5D6A7;
}

.stato-ko {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.stato-warning {
    background: #FFF8E1;
    color: #E65100;
    border: 1px solid #FFE082;
}

/* --- ICONE CATEGORIE --- */
.badge-categories {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px 0;
    flex-wrap: wrap;
}

.badge-cat-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #2E7D32;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

/* --- LISTA DOCUMENTI --- */
.doc-list-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 16px;
    text-align: center;
}

.doc-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    margin-bottom: 10px;
    background: #fff;
    transition: box-shadow 0.2s;
}

.doc-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.doc-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.doc-icon-ok {
    background: #E8F5E9;
    color: #2E7D32;
}

.doc-icon-ko {
    background: #FFEBEE;
    color: #C62828;
}

.doc-icon-warning {
    background: #FFF8E1;
    color: #E65100;
}

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-scadenza {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
}

.doc-scadenza-ok {
    color: #2E7D32;
}

.doc-scadenza-ko {
    color: #C62828;
}

.doc-scadenza-warning {
    color: #E65100;
}

.doc-nome {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-arrow {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
}

.doc-arrow-ok {
    background: #2E7D32;
    color: #fff;
}

.doc-arrow-ko {
    background: #C62828;
    color: #fff;
}

.doc-arrow-warning {
    background: #E65100;
    color: #fff;
}

/* --- INFO AZIENDA --- */
.azienda-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    margin-top: 15px;
}

.azienda-info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
    margin-bottom: 8px;
}

.azienda-info-nome {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.azienda-info-detail {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}

/* --- MESSAGGI --- */
.badge-alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.badge-alert-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.badge-alert-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #A5D6A7;
}

.badge-alert-info {
    background: #E3F2FD;
    color: #1565C0;
    border: 1px solid #90CAF9;
}

.badge-alert-warning {
    background: #FFF8E1;
    color: #E65100;
    border: 1px solid #FFE082;
}

/* --- OTP CANALI --- */
.otp-canali {
    font-size: 13px;
    color: #888;
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.otp-canali span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- RE-INVIO OTP --- */
.otp-resend {
    margin-top: 20px;
    text-align: center;
}

.otp-resend a {
    color: #2E7D32;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.otp-resend a:hover {
    text-decoration: underline;
}

/* --- FOOTER --- */
.badge-footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #eee;
}

.badge-footer-text {
    font-size: 11px;
    color: #aaa;
}

.badge-footer-link {
    color: #2E7D32;
    text-decoration: none;
    font-weight: 500;
}

/* --- LOADING SPINNER --- */
.badge-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: badge-spin 0.8s ease-in-out infinite;
}

@keyframes badge-spin {
    to { transform: rotate(360deg); }
}

/* --- ERRORE PAGINA --- */
.badge-error-page {
    text-align: center;
    padding: 60px 20px;
}

.badge-error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.badge-error-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.badge-error-message {
    font-size: 15px;
    color: #666;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* --- DATA ULTIMO AGGIORNAMENTO --- */
.badge-last-update {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding: 10px 0;
}

/* --- RESPONSIVE --- */
@media (max-width: 380px) {
    .otp-inputs input {
        width: 42px;
        height: 50px;
        font-size: 20px;
    }
    .otp-inputs {
        gap: 6px;
    }
}

a.doc-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
a.doc-item-link:hover .doc-item,
a.doc-item-link:active .doc-item {
    background-color: #f0f0f0;
}

@media (min-width: 481px) {
    body {
        padding: 20px 0;
    }
    .badge-container {
        border-radius: 16px;
        min-height: auto;
        margin: 20px auto;
        overflow: hidden;
    }
}
