/*
    QR Creator – Utility Page
    ══════════════════════════════════════════════════
    Parte della sezione "Lab & Utility" di AttilioViscido.it

    DESIGN SYSTEM:
    Questo foglio di stile ridefinisce localmente le stesse variabili
    del sito principale (NON le importa con @import), così ogni utility
    è autonoma e trasportabile senza dipendenze esterne dal sito.

    Per una nuova utility: copia il blocco :root e le classi
    .bg-grid, .bg-glow, .site-header, .back-link, .app-wrapper
    come base di partenza, poi aggiungi i tuoi stili specifici.

    Palette (identica al sito principale css/style.css):
      --primary:       #076FB7  (blu brand B.I. Strategy)
      --primary-light: #2A8CD4  (hover/gradiente)
      --accent:        #D3B574  (oro per accenti premium)
      --dark-bg:       #0D1117  (sfondo scuro, stile GitHub Dark)
      --card-bg:       #161B22  (sfondo card e contenitori)
      --text-main:     #c9d1d9  (testo su sfondo scuro)

    SEZIONI PRINCIPALI:
      1. Design tokens (:root)
      2. Reset & base
      3. Animated background (.bg-grid, .bg-glow)
      4. Compact Site Header (.site-header, .back-link, .breadcrumb)
      5. Layout (.app-wrapper, .app-card)
      6. App Header + Reset button
      7. Type selector (URL / Testo)
      8. Input group + Error message
      9. Generate button
     10. Result container + QR wrapper
         - .qr-frame-label      → etichetta "SCAN ME" (visibile con .frame--label)
         - .frame--classic      → cornice scura
         - .frame--gold         → cornice oro arrotondata
         - .frame--corners      → staffe dorate agli angoli (ripristina ::before/::after)
         - .frame--label        → mostra l'etichetta "SCAN ME" in basso
     11. Action buttons (download)
     12. Frame Selector (.frame-selector, .frame-opt, .frame-thumb)
         - .thumb--none / --classic / --gold / --corners / --label
     13. Shake animation
     14. Responsive (max-width: 480px)
*/

/* ── Design tokens ─────────────────────────────── */
/* Stesse variabili del sito principale, ridefinite localmente per autonomia */
:root {
    --primary: #076FB7;
    --primary-light: #2A8CD4;
    --accent: #D3B574;
    --accent-hover: #b89a57;
    --dark-bg: #0D1117;
    --card-bg: #161B22;
    --card-border: rgba(211, 181, 116, 0.15);
    --text-main: #c9d1d9;
    --text-white: #ffffff;
    --text-muted: #8b949e;
    --error: #f85149;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Reset & base ───────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ── Animated background ────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(7, 111, 183, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 111, 183, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

/*
    Sfere di luce sfocate (glow) con animazione fluttuante.
    glow-1 = sfera blu (in alto a destra)
    glow-2 = sfera oro (in basso a sinistra)
    Creano profondità e coerenza con il brand cromatico del sito.
*/
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: driftGlow 18s ease-in-out infinite alternate;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -80px;
    left: -80px;
    animation-delay: -9s;
    opacity: 0.1;
}

@keyframes driftGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-40px, 40px) scale(1.1);
    }

    100% {
        transform: translate(40px, -20px) scale(0.95);
    }
}

/* ── Compact Site Header ────────────────────────── */
/*
    Header ridotto (60px) che sostituisce il nav completo del sito.
    Mostra il link di ritorno alla home e un breadcrumb "Lab & Utility".
    DEVE essere presente in TUTTE le utility per coerenza di navigazione.
*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.back-link i {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: var(--transition);
}

.back-link:hover i {
    transform: translateX(-3px);
    opacity: 1;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-white);
}

.logo-dot {
    color: var(--accent);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.breadcrumb i {
    color: var(--accent);
    font-size: 0.8rem;
}

/* ── Main Wrapper ───────────────────────────────── */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 540px;
    padding: 90px 20px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── App Card ───────────────────────────────────── */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 36px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── App Header ─────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-icon-wrap {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 1.5rem;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(7, 111, 183, 0.4);
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-white);
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.reset-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    padding: 9px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.reset-btn:hover {
    color: var(--accent);
    background: rgba(211, 181, 116, 0.1);
    border-color: var(--accent);
}

.reset-btn:active {
    transform: rotate(-180deg);
}

/* ── Type Selector ──────────────────────────────── */
.type-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 5px;
    gap: 5px;
}

.type-selector input[type="radio"] {
    display: none;
}

.selector-btn {
    flex: 1;
    text-align: center;
    padding: 10px 14px;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.type-selector input[type="radio"]:checked+.selector-btn {
    color: var(--text-white);
    background: var(--primary);
    box-shadow: 0 4px 15px rgba(7, 111, 183, 0.35);
}

/* ── Input Group ────────────────────────────────── */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.input-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-white);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    resize: none;
    transition: var(--transition);
    line-height: 1.5;
}

.input-group textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(7, 111, 183, 0.06);
    box-shadow: 0 0 0 3px rgba(7, 111, 183, 0.2);
}

.input-group.hidden {
    display: none;
}

/* ── WiFi Fields ───────────────────────────────── */
.wifi-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.field-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sub-label {
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em;
}

.field-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 12px;
}

.wifi-fields input,
.wifi-fields select {
    width: 100%;
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-white);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
}

.wifi-fields select {
    cursor: pointer;
}

.wifi-fields input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Fix per la leggibilità delle opzioni su browser che usano stili nativi chiari */
.wifi-fields select option {
    background-color: var(--card-bg);
    color: var(--text-white);
}

.wifi-fields input:focus,
.wifi-fields select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(7, 111, 183, 0.15);
}

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    padding-right: 40px;
}

.toggle-pass {
    position: absolute;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.toggle-pass:hover {
    color: var(--text-white);
}

/* ── Error Message ──────────────────────────────── */
.error-msg {
    color: var(--error);
    font-size: 0.82rem;
    display: none;
    align-items: center;
    gap: 6px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Generate Button ────────────────────────────── */
.generate-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(7, 111, 183, 0.35);
    letter-spacing: 0.02em;
}

.generate-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(7, 111, 183, 0.5);
}

.generate-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

.btn-icon {
    color: var(--accent);
    transition: var(--transition);
    font-size: 0.9rem;
}

.generate-btn:hover .btn-icon {
    transform: scale(1.3) rotate(15deg);
}

/* ── Result Container ───────────────────────────── */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.qr-wrapper {
    width: 210px;
    height: 210px;
    background: #ffffff;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(211, 181, 116, 0.2), 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* Gold corner accents – hidden by default, shown only with frame--corners */
.qr-wrapper::before,
.qr-wrapper::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-color: var(--accent);
    border-style: solid;
    display: none;
}

.qr-wrapper::before {
    top: 8px;
    left: 8px;
    border-width: 2px 0 0 2px;
    border-radius: 4px 0 0 0;
}

.qr-wrapper::after {
    bottom: 8px;
    right: 8px;
    border-width: 0 2px 2px 0;
    border-radius: 0 0 4px 0;
}

/* ── Cornice: SCAN ME label (assoluta, in basso) ────── */
.qr-frame-label {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-align: center;
    padding: 7px 0;
    border-radius: 0 0 20px 20px;
}

/* ── Frame preview – classi sul .qr-wrapper ─────────── */
.qr-wrapper.frame--classic {
    border: 7px solid #0D1117;
    border-radius: 4px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.4);
}

.qr-wrapper.frame--gold {
    border: 5px solid var(--accent);
    border-radius: 20px;
    box-shadow: 0 0 0 1px rgba(211, 181, 116, 0.25), 0 0 22px rgba(211, 181, 116, 0.25);
}

.qr-wrapper.frame--corners::before,
.qr-wrapper.frame--corners::after {
    display: block;
}

.qr-wrapper.frame--label .qr-frame-label {
    display: block;
}

.qr-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    transition: opacity 0.4s ease;
}

.placeholder-icon {
    font-size: 2.8rem;
    color: #c8d1d9;
}

.qr-placeholder span {
    font-size: 0.82rem;
    font-weight: 500;
    color: #94a3b8;
    font-family: 'Outfit', sans-serif;
}

#qrcode {
    opacity: 0;
    transform: scale(0.88);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#qrcode.visible {
    opacity: 1;
    transform: scale(1);
}

.qr-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

#qrcode img,
#qrcode canvas {
    max-width: 100%;
    max-height: 100%;
}

/* ── Action Buttons ─────────────────────────────── */
.action-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.action-buttons.hidden {
    display: none;
}

.action-btn {
    flex: 1;
    background: rgba(7, 111, 183, 0.1);
    border: 1px solid rgba(7, 111, 183, 0.3);
    color: var(--primary-light);
    padding: 12px;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(7, 111, 183, 0.35);
}

/* ── Shake animation ────────────────────────────── */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.45s cubic-bezier(.36, .07, .19, .97) both;
}

/* ── Frame Selector ─────────────────────────────────── */
.frame-selector {
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.frame-selector.hidden {
    display: none;
}

.frame-selector-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.frame-selector-label i {
    color: var(--accent);
    font-size: 0.75rem;
}

.frame-options {
    display: flex;
    gap: 6px;
    justify-content: space-between;
}

.frame-opt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 4px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.frame-opt:hover {
    background: rgba(255, 255, 255, 0.05);
}

.frame-opt input[type="radio"] {
    display: none;
}

.frame-opt:has(input:checked) {
    border-color: var(--primary);
    background: rgba(7, 111, 183, 0.12);
}

.frame-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.frame-opt:has(input:checked) .frame-name {
    color: var(--primary-light);
}

/* ── Frame thumbnails ────────────────────────────────── */
.frame-thumb {
    width: 36px;
    height: 36px;
    background: #ffffff;
    border-radius: 5px;
    position: relative;
    display: block;
    flex-shrink: 0;
}

/* Nessuna – plain white */
.thumb--none {
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Classica – thick dark border */
.thumb--classic {
    border: 5px solid #0D1117;
    border-radius: 1px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

/* Oro – gold rounded border */
.thumb--gold {
    border: 3px solid #D3B574;
    border-radius: 6px;
    box-shadow: 0 0 6px rgba(211, 181, 116, 0.4);
}

/* Angoli – gold corner brackets */
.thumb--corners::before,
.thumb--corners::after {
    content: '';
    position: absolute;
    width: 9px;
    height: 9px;
    border-color: #D3B574;
    border-style: solid;
}

.thumb--corners::before {
    top: 3px;
    left: 3px;
    border-width: 2px 0 0 2px;
}

.thumb--corners::after {
    bottom: 3px;
    right: 3px;
    border-width: 0 2px 2px 0;
}

/* Scan Me – label at bottom */
.thumb--label {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.thumb--label::after {
    content: 'SCAN';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #076FB7;
    color: #ffffff;
    font-size: 5.5px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.08em;
    text-align: center;
    padding: 2.5px 0;
    border-radius: 0 0 4px 4px;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
    .app-card {
        padding: 24px 20px;
        border-radius: 20px;
        gap: 22px;
    }

    .app-header h1 {
        font-size: 1.35rem;
    }

    .site-header-inner {
        padding: 0 16px;
    }

    .breadcrumb {
        display: none;
    }

    .frame-options {
        gap: 4px;
    }

    .frame-thumb {
        width: 30px;
        height: 30px;
    }
}