:root {
    --bg: #070b10;
    --card: #101820;

    --primary: #00bcd4;
    --primary-dark: #0097a7;

    --text: #ffffff;
    --muted: #9fb3bd;

    --success: #4caf50;
    --danger: #ff5252;

    --border: rgba(255,255,255,.08);

    --shadow:
        0 20px 60px rgba(0,0,0,.45);
}

/* ===================================================== */
/* RESET */
/* ===================================================== */

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

/* ===================================================== */
/* BASE */
/* ===================================================== */

html,
body {
    width: 100%;
    min-height: 100vh;
    background:
        radial-gradient(
            circle at top,
            rgba(0,188,212,.15),
            transparent 40%
        ),
        linear-gradient(
            180deg,
            #081018 0%,
            #05070a 100%
        );

    color: var(--text);

    font-family:
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

/* ===================================================== */
/* LAYOUT DE DUAS COLUNAS */
/* ===================================================== */

.main-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.left-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(20px, 4vw, 40px);
    border-right: 1px solid var(--border);
    animation: fadeIn .8s ease;
}

.side-image {
    max-width: 85%;
    max-height: 80vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 10px 30px rgba(0, 188, 212, 0.25));
    animation: logoFloat 4s ease-in-out infinite;
}

.right-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(16px, 3vw, 40px);
}

/* ===================================================== */
/* CONTAINER PRINCIPAL */
/* ===================================================== */

.container {
    width: 92%;
    max-width: 100%;
    background: rgba(16,24,32,.92);
    border: 1px solid var(--border);
    border-radius: clamp(18px, 2vw, 28px);
    padding: clamp(24px, 4vh, 48px);
    text-align: center;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    animation: fadeIn .6s ease;
}

/* ===================================================== */
/* ANIMAÇÕES */
/* ===================================================== */

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

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

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

@keyframes logoFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0px); }
}

/* ===================================================== */
/* TEXTOS E TIPOGRAFIA */
/* ===================================================== */

h1 {
    font-size: clamp(1.8rem, 4.5vh, 3.2rem);
    line-height: 1.15;
    margin-bottom: clamp(10px, 1.5vh, 16px);
    font-weight: 700;
}

p {
    color: var(--muted);
    font-size: clamp(.95rem, 2vh, 1.25rem);
    line-height: 1.6;
}

/* ===================================================== */
/* QR CODE */
/* ===================================================== */

.qrcode-area {
    margin-top: clamp(20px, 3.5vh, 40px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 2vh, 24px);
}

#qrcode-wrapper {
    background: white;
    padding: clamp(16px, 2.5vh, 28px);
    border-radius: clamp(14px, 2vw, 24px);
    box-shadow: 0 12px 35px rgba(0,0,0,.35);
}

#qrcode canvas,
#qrcode img {
    width: min(280px, 38vw, 38vh) !important;
    height: min(280px, 38vw, 38vh) !important;
}

/* ===================================================== */
/* TOKEN */
/* ===================================================== */

.token-box {
    width: 100%;
    max-width: 520px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    border-radius: clamp(12px, 2vw, 16px);
    padding: clamp(12px, 2vh, 18px);
}

.token-label {
    font-size: clamp(.72rem, 1.2vh, .85rem);
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.token-value {
    font-family: Consolas, monospace;
    font-size: clamp(.85rem, 1.6vh, 1.1rem);
    word-break: break-all;
    color: #e0f7fa;
}

/* ===================================================== */
/* STATUS */
/* ===================================================== */

.status-area {
    margin-top: clamp(20px, 3vh, 32px);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: clamp(10px, 1.5vh, 14px) clamp(16px, 2vw, 22px);
    border-radius: 999px;
    background: rgba(0,188,212,.12);
    border: 1px solid rgba(0,188,212,.25);
    color: #b2ebf2;
    font-size: clamp(.85rem, 1.5vh, 1rem);
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1.5s infinite;
}

/* ===================================================== */
/* SUCCESS & LOADER */
/* ===================================================== */

.hidden {
    display: none !important;
}

.success-icon {
    width: clamp(80px, 11vh, 100px);
    height: clamp(80px, 11vh, 100px);
    margin: 0 auto clamp(18px, 2vh, 25px);
    border-radius: 50%;
    background: rgba(76,175,80,.12);
    border: 2px solid rgba(76,175,80,.25);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(36px, 5.5vh, 46px);
    color: var(--success);
}

.success-title {
    color: var(--success);
}

.device-name {
    color: white;
    font-weight: bold;
}

.loader {
    margin: clamp(20px, 3.5vh, 40px) auto 0;
    width: clamp(42px, 6.5vh, 56px);
    height: clamp(42px, 6.5vh, 56px);
    border-radius: 50%;
    border: 5px solid rgba(255,255,255,.08);
    border-top-color: var(--success);
    animation: spin 1s linear infinite;
}

.footer {
    margin-top: clamp(20px, 3vh, 32px);
    font-size: clamp(.75rem, 1.3vh, .95rem);
    color: rgba(255,255,255,.35);
}

/* ===================================================== */
/* RESPONSIVIDADE E ADAPTAÇÃO */
/* ===================================================== */

@media (max-width: 950px), (orientation: portrait) {
    html, body {
        overflow: hidden; /* Trava o scroll global novamente */
    }

    .main-wrapper {
        flex-direction: column;
        height: 100vh; /* Garante que o wrapper ocupe exatamente a altura da tela */
    }

    .left-panel {
        flex: none;
        width: 100%;
        height: 20vh; /* Reduzido de 35vh para 20vh para liberar espaço para o container */
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 15px;
    }

    .side-image {
        max-width: 100%;
        max-height: 100%;
    }

    .right-panel {
        flex: 1;
        width: 100%;
        height: 80vh; /* Ocupa os 80% restantes da tela */
        padding: 12px; /* Reduzido para espremer o conteúdo para dentro da tela */
    }

    .container {
        width: 95%;
        max-height: 78vh; /* Limita a altura do container para não estourar os 80vh do painel */
        padding: clamp(16px, 3vh, 28px); /* Reduzido o padding interno no modo vertical */
    }

    /* Ajustes finos nos textos para o modo vertical */
    h1 {
        font-size: clamp(1.5rem, 3.5vh, 2.2rem);
        margin-bottom: 8px;
    }

    p {
        font-size: clamp(0.85rem, 1.6vh, 1rem);
    }

    .qrcode-area {
        margin-top: clamp(12px, 2vh, 24px);
        gap: clamp(10px, 1.5vh, 16px);
    }

    #qrcode-wrapper {
        padding: 12px;
    }

    /* Reduz o QR Code dinamicamente para caber na tela vertical */
    #qrcode canvas,
    #qrcode img {
        width: min(200px, 28vh) !important;
        height: min(200px, 28vh) !important;
    }

    .token-box {
        padding: 10px;
    }

    .status-area {
        margin-top: clamp(12px, 2vh, 20px);
    }
}

@media (max-height: 750px) {
    .container {
        padding: clamp(14px, 2vh, 24px);
    }
    .qrcode-area {
        margin-top: 16px;
    }
    .footer {
        margin-top: 14px;
    }
}