/* ================================================================
   AtleaQR — Dark kiosk theme (richiama Palestra)
   Palette: #0D0D1A bg, #12122B card, #FF6B35/#FF8C61 arancio
   ================================================================ */

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

:root {
    --bg:          #0D0D1A;
    --bg-card:     #12122B;
    --bg-card2:    #1a1a35;
    --orange:      #9ca3af;
    --orange-lite: #c5cad3;
    --orange-glow: rgba(156, 163, 175, 0.35);
    --text:        #FFFFFF;
    --text-sec:    #CFCFE2;
    --green:       #22C55E;
    --red:         #EF4444;
    --border:      rgba(255,255,255,0.08);
    --radius:      16px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ── App shell ─────────────────────────────────────────────── */
.app-shell { height: 100vh; display: flex; flex-direction: column; }

/* ── Header ────────────────────────────────────────────────── */
.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    transition: opacity 0.3s ease, max-height 0.3s ease;
    overflow: hidden;
    max-height: 80px;
    opacity: 1;
}

.scanner-header.header-hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom: none;
    pointer-events: none;
}

.header-brand { display: flex; align-items: center; gap: 10px; }

.brand-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.brand-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--orange-lite));
    box-shadow: 0 0 8px var(--orange);
}

.brand-name {
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    color: var(--text);
}
.brand-name strong { color: var(--orange); }

.btn-settings {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-sec);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.btn-settings:hover { background: var(--bg-card2); color: var(--orange); }
.btn-settings svg { width: 20px; height: 20px; }

/* ── Scanner page ───────────────────────────────────────────── */
.scanner-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    position: relative;
}

.scanner-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    gap: 24px;
    overflow: hidden;
}

.scan-prompt {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.scan-sub {
    font-size: 0.82rem;
    color: var(--text-sec);
    text-align: center;
    opacity: 0.7;
}

/* ── Input nascosto per lettore HID ────────────────────────── */
.qr-hidden-input {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ── Viewfinder scanner ──────────────────────────────────────── */
.viewfinder-wrapper {
    position: relative;
    width: min(280px, 72vw);
    height: min(280px, 72vw);
    flex-shrink: 0;
}

.scan-frame {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    overflow: hidden;
}

.scan-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 107, 53, 0.04);
    border-radius: 4px;
}

.corner {
    position: absolute;
    width: 32px;
    height: 32px;
    border-color: var(--orange);
    border-style: solid;
    z-index: 1;
}
.corner.tl { top: 0;    left: 0;   border-width: 3px 0 0 3px; border-radius: 8px 0 0 0; }
.corner.tr { top: 0;    right: 0;  border-width: 3px 3px 0 0; border-radius: 0 8px 0 0; }
.corner.bl { bottom: 0; left: 0;   border-width: 0 0 3px 3px; border-radius: 0 0 0 8px; }
.corner.br { bottom: 0; right: 0;  border-width: 0 3px 3px 0; border-radius: 0 0 8px 0; }

.scan-line {
    position: absolute;
    left: 6px;
    right: 6px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--orange) 30%, var(--orange-lite) 50%, var(--orange) 70%, transparent 100%);
    box-shadow: 0 0 10px var(--orange), 0 0 20px var(--orange-glow);
    animation: scanMove 2.4s ease-in-out infinite;
    top: 6px;
}

@keyframes scanMove {
    0%   { top: 6px;              opacity: 1; }
    48%  { top: calc(100% - 8px); opacity: 1; }
    50%  { top: calc(100% - 8px); opacity: 0; }
    52%  { top: 6px;              opacity: 0; }
    54%  { top: 6px;              opacity: 1; }
    100% { top: 6px;              opacity: 1; }
}

/* ── Spinner processing ──────────────────────────────────────── */
.hid-icon-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 52px; height: 52px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Result overlay ─────────────────────────────────────────── */
.result-overlay {
    width: 100%;
    max-width: 380px;
    border-radius: var(--radius);
    padding: 36px 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: fadeInUp 0.3s ease;
}

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

.result-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.4); }
.result-error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.4); }

.result-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.result-success .result-icon { background: rgba(34,197,94,0.2); color: var(--green); }
.result-error   .result-icon { background: rgba(239,68,68,0.2);  color: var(--red); }
.result-icon svg { width: 36px; height: 36px; }

.result-message {
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
}

.result-tornello {
    font-size: 0.9rem;
    color: var(--green);
    letter-spacing: 0.2px;
}

.result-countdown {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.countdown-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    position: relative;
    overflow: hidden;
}
.countdown-bar::after {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: var(--orange);
    animation: countdown linear forwards;
    animation-duration: inherit;
    width: 100%;
}

@keyframes countdown { from { width: 100%; } to { width: 0%; } }

.result-countdown span { font-size: 0.82rem; color: var(--text-sec); }

.btn-copy {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card2);
    color: var(--text-sec);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    align-self: stretch;
}
.btn-copy:hover { background: var(--bg-card); color: var(--text); }

/* ── Tornello badge ─────────────────────────────────────────── */
.tornello-badge {
    position: fixed;
    bottom: 16px; right: 16px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    pointer-events: none;
}
.tornello-badge.connected { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.35); }

/* ── Settings page ──────────────────────────────────────────── */
.settings-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.settings-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 40px;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-card h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}

label {
    font-size: 0.85rem;
    color: var(--text-sec);
}

.settings-input {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    padding: 10px 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}
.settings-input:focus { border-color: var(--orange); }

.serial-status-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.serial-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-ok  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-off { background: #555; }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
}
.toggle-row label { font-size: 0.9rem; color: var(--text-sec); }
.toggle-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--orange); cursor: pointer; }

.btn-primary {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(90deg, var(--orange), var(--orange-lite));
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-secondary {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card2);
    color: var(--text-sec);
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-outline {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid var(--orange);
    background: transparent;
    color: var(--orange);
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-outline:disabled { opacity: 0.4; }

.input-inline {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    padding: 8px 12px;
    outline: none;
}
.input-inline:focus { border-color: var(--orange); }

.btn-save { align-self: stretch; padding: 14px; font-size: 1rem; }

.feedback {
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 500;
}
.feedback-ok  { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: var(--green); }
.feedback-err { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.3);  color: var(--red); }

.warn { color: #F59E0B; font-size: 0.88rem; }

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.88rem;
}
.config-row:last-of-type { border-bottom: none; }
.config-label { color: var(--text-muted); flex-shrink: 0; }
.config-value { color: var(--text-primary); text-align: right; word-break: break-all; }

/* ── Splash loading ─────────────────────────────────────────── */
.splash {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
}
.splash-dot { width: 14px; height: 14px; animation: pulse 1.4s ease-in-out infinite; }
.splash-brand { font-size: 1.8rem; }

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--orange); }
    50%       { opacity: 0.5; box-shadow: 0 0 20px var(--orange); }
}

/* ── Blazor error ───────────────────────────────────────────── */
#blazor-error-ui {
    background: var(--red);
    bottom: 0; left: 0; right: 0;
    color: #fff;
    display: none;
    padding: 10px 16px;
    position: fixed;
    z-index: 1000;
    font-size: 0.9rem;
}
#blazor-error-ui .reload { color: #fff; font-weight: bold; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ── Footer logo ────────────────────────────────────────────── */
.scanner-footer {
    position: fixed;
    bottom: 1.2rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
}
.footer-logo {
    height: 28px;
    opacity: 0.6;
    filter: brightness(0) invert(1);
}

/* ── Header logo (sotto topbar) ─────────────────────────────── */
.scanner-header-logo {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0 0.5rem;
}
.header-logo {
    height: 36px;
}
