/* styles.css - Stili per Registro Ospiti (ottimizzato per tablet) */

:root {
    --primary-color:  #059669;
    --primary-dark:   #047857;
    --primary-tint:   #d1fae5;
    --radius-card:    12px;
    --radius-btn:     8px;
    --btn-background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(150deg, #e2e8f0 0%, #eef2f6 60%, #f1f5f9 100%);
    min-height: 100vh;
    padding: 6px;
    color: #1f2937;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.header {
    background: white;
    border-radius: var(--radius-card);
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 2px 10px rgba(30, 41, 59, 0.09);
    padding: 10px 16px;
    margin-bottom: 6px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-text {
    flex: 1;
}

.header h1 {
    font-size: 1.6rem;
    color: var(--primary-color);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.header-sub {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 400;
    margin-top: 1px;
    letter-spacing: 0.02em;
}

.header-logo {
    flex-shrink: 0;
    max-width: 180px;
}

.header-logo img {
    max-height: 42px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Language toggle */
.lang-toggle {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.lang-btn {
    padding: 6px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.flag-icon {
    display: block;
    border-radius: 2px;
    flex-shrink: 0;
}

.lang-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.lang-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Messaggi */
.messaggio {
    background: white;
    border-radius: var(--radius-card);
    padding: 14px 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 52, 98, 0.12);
    animation: slideIn 0.3s ease-out;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.messaggio.hidden {
    display: none;
}

.messaggio.successo {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.messaggio.errore {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.messaggio::before {
    content: '✓';
    font-size: 20px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: currentColor;
    color: white;
    border-radius: 50%;
    flex-shrink: 0;
}

.messaggio.errore::before {
    content: '✗';
}

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

/* Selettore Modalità */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.mode-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-card);
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0, 52, 98, 0.07);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 52, 98, 0.13);
    border-color: #cbd5e1;
}

.mode-btn svg {
    color: #94a3b8;
    transition: color 0.2s ease;
}

.mode-btn h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #374151;
    letter-spacing: 0.01em;
}

.mode-btn-entrata.active {
    border-color: #22c55e;
    background: linear-gradient(160deg, #f0fdf4 0%, #dcfce7 100%);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.18);
}

.mode-btn-entrata.active svg {
    color: #16a34a;
}

.mode-btn-entrata.active h3 {
    color: #166534;
}

.mode-btn-uscita.active {
    border-color: #334155;
    background: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
    box-shadow: 0 4px 16px rgba(30, 41, 59, 0.14);
}

.mode-btn-uscita.active svg {
    color: #475569;
}

.mode-btn-uscita.active h3 {
    color: #1e293b;
}

/* Form Container */
.form-container {
    background: white;
    border-radius: var(--radius-card);
    box-shadow: 0 4px 12px rgba(0, 52, 98, 0.10);
    padding: 16px;
    margin-bottom: 12px;
    border-top: 3px solid var(--primary-color);
}

.form-section {
    display: none;
}

.form-section.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Campo badge con wrapper icona */
.badge-scan-group {
    margin-bottom: 16px;
}

.badge-scan-group > label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.badge-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: #fef9c3;
    border: 2px dashed #fbbf24;
    border-radius: 8px;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.badge-input-wrapper.badge-verifica {
    background: #fffbeb;
    border-style: solid;
    border-color: #f59e0b;
    animation: badge-pulse 0.7s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

.badge-input-wrapper.badge-scansionato {
    background: #f0fdf4;
    border-style: solid;
    border-color: #22c55e;
}

.badge-scan-icon {
    flex-shrink: 0;
    color: #d97706;
    transition: color 0.25s ease;
}

.badge-input-wrapper.badge-scansionato .badge-scan-icon {
    color: #22c55e;
}

.badge-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: #92400e;
    outline: none;
    min-width: 0;
}

.badge-input-wrapper.badge-scansionato input {
    color: #166534;
}

/* Campi visitatore: bloccati finché il badge non è scansionato */
.campi-visitatore {
    transition: opacity 0.25s ease;
    margin-top: 4px;
}

.campi-bloccati {
    opacity: 0.38;
    pointer-events: none;
}

/* Mantenuto per compatibilità con codice esistente */
.badge-input {
    background-color: #fef3c7 !important;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 1.05rem !important;
}

.help-text {
    margin-top: 5px;
    font-size: 0.8rem;
    color: #6b7280;
}

/* Indicatore scansione badge entrata */

.submit-btn {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

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

.submit-btn-entrata { background: var(--btn-background); }
.submit-btn-entrata:hover { background: var(--primary-dark); }

.submit-btn-uscita { background: #1e293b; }
.submit-btn-uscita:hover { background: #0f172a; }

/* Statistiche */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-card);
    padding: 10px 14px;
    box-shadow: 0 4px 12px rgba(0, 52, 98, 0.10);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid var(--primary-color);
}

.stat-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-tint);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary-color);
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 3px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-time {
    font-size: 0.95rem;
}

/* PIN reception: dentro la colonna QR */
.pin-reception {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #fffbeb;
    border: 1.5px solid #fbbf24;
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
    margin-top: 4px;
}

.pin-reception-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pin-reception-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #92400e;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.15em;
}

/* Layout a due colonne: form a sinistra, QR a destra (landscape tablet) */
.page-layout {
    max-width: 900px;
    margin: 0 auto;
}

/* Attivato via JS su tablet landscape (più affidabile dei media query su Android vecchi) */
body.landscape-layout .page-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    max-width: 1100px;
}

body.landscape-layout .page-layout .container {
    flex: 1;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
}

body.landscape-layout .page-layout .qr-section {
    width: 174px;
    flex-shrink: 0;
    margin-top: 0;
    position: sticky;
    top: 6px;
}

body.landscape-layout .header {
    max-width: 1100px;
}

/* Fallback media query per browser moderni */
@media (orientation: landscape) and (min-width: 600px) {
    body:not(.landscape-layout) .page-layout {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 12px;
        max-width: 1100px;
    }

    body:not(.landscape-layout) .page-layout .container {
        flex: 1;
        min-width: 0;
        margin-left: 0;
        margin-right: 0;
    }

    body:not(.landscape-layout) .page-layout .qr-section {
        width: 174px;
        flex-shrink: 0;
        margin-top: 0;
        position: sticky;
        top: 6px;
    }

    body:not(.landscape-layout) .header {
        max-width: 1100px;
    }
}

/* Responsive portrait tablet / mobile */
@media (max-width: 600px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .mode-selector {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }
}

/* Sezione QR check-in da smartphone */
.qr-section {
    background: white;
    border-radius: var(--radius-card);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 16px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.qr-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.qr-img {
    width: 150px;
    height: 150px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px;
    background: white;
}

.qr-section-note {
    font-size: 0.9rem;
    color: #374151;
    text-align: center;
}

.qr-section-validity {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Demo panel */
.demo-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 300px;
    background: #1e1b4b;
    border: 2px solid #6366f1;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 1000;
}

.demo-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-label {
    background: #6366f1;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 2px 7px;
    border-radius: 4px;
}

.demo-title {
    color: #c7d2fe;
    font-size: 0.82rem;
    font-weight: 600;
}

.demo-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.demo-preset-btn {
    background: #312e81;
    border: 1px solid #4f46e5;
    border-radius: 6px;
    color: #e0e7ff;
    font-size: 0.78rem;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.demo-preset-btn:hover {
    background: #4f46e5;
}

.demo-custom {
    display: flex;
    gap: 6px;
}

.demo-custom input {
    flex: 1;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid #4f46e5;
    background: #312e81;
    color: #e0e7ff;
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
}

.demo-custom input::placeholder {
    color: #818cf8;
}

.demo-custom input:focus {
    outline: none;
    border-color: #818cf8;
}

.demo-simulate-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #6366f1;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.demo-simulate-btn:hover {
    background: #4f46e5;
}

/* Stato di caricamento */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Classi tabella mantenute per compatibilita' con app.js */
.badge-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #1f2937;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-presenti  { background: #dcfce7; color: #166534; }
.status-completato { background: #e5e7eb; color: #374151; }

/* ── Tastiera virtuale ── */
.vkb-panel {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e293b;
    border-top: 2px solid #334155;
    padding: 8px 10px 14px;
    z-index: 9999;
    user-select: none;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}

.vkb-panel.vkb-visible {
    display: block;
}

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

.vkb-label {
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.vkb-done {
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 7px 18px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    touch-action: manipulation;
}

.vkb-done:active {
    background: #16a34a;
}

.vkb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}

.vkb-row-special {
    margin-top: 2px;
}

.vkb-key {
    background: #334155;
    color: #e2e8f0;
    border: none;
    border-radius: 5px;
    min-width: 42px;
    height: 40px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s;
    touch-action: manipulation;
    padding: 0 6px;
}

.vkb-key:active {
    background: #64748b;
}

.vkb-key-caps {
    min-width: 56px;
    font-size: 1.1rem;
}

.vkb-caps-active {
    background: #3b82f6 !important;
    color: white;
}

.vkb-key-space {
    flex: 1;
    max-width: 280px;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.vkb-key-back {
    min-width: 56px;
    font-size: 1.15rem;
}

/* Garantisce risposta rapida al tocco anche sui campi del form */
.form-group input {
    touch-action: manipulation;
}

/* ── Overlay benvenuto check-in web ── */
.checkin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.checkin-overlay.visible {
    display: flex;
    animation: overlayFadeIn 0.3s ease-out;
}

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

.checkin-overlay-card {
    background: white;
    border-radius: 20px;
    padding: 44px 36px 36px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    animation: overlaySlideUp 0.3s ease-out;
}

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

.checkin-overlay-icon {
    width: 84px;
    height: 84px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2.8rem;
    color: #22c55e;
}

.checkin-overlay-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 12px;
}

.checkin-overlay-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #166534;
    margin-bottom: 4px;
}

.checkin-overlay-company {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 20px;
}

.checkin-overlay-note {
    font-size: 0.82rem;
    color: #9ca3af;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.checkin-overlay-bar {
    height: 5px;
    background: #f3f4f6;
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.checkin-overlay-progress {
    height: 100%;
    background: #22c55e;
    border-radius: 3px;
    width: 100%;
}

.checkin-overlay-close {
    background: none;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 9px 28px;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    font-family: inherit;
}

.checkin-overlay-close:hover {
    border-color: #9ca3af;
    color: #374151;
}

/* Privacy notice sotto i form */
.privacy-notice {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #9ca3af;
    text-align: center;
    line-height: 1.4;
}

.privacy-notice a {
    color: #6b7280;
    text-decoration: underline;
}

.privacy-notice a:hover {
    color: #374151;
}

/* Brand footer */
.brand-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 16px 20px;
    font-size: 0.7rem;
    color: #94a3b8;
    user-select: none;
}

.brand-footer strong {
    font-weight: 600;
    color: #64748b;
}
