/* ============================================================
   Variáveis — Light Mode (padrão)
   ============================================================ */
:root {
    --bg:              #f8f8f8;
    --surface:         #ffffff;
    --border:          #e4e4e4;
    --text-primary:    #111111;
    --text-secondary:  #666666;
    --text-hint:       #999999;
    --accent:          #111111;
    --accent-fg:       #ffffff;
    --accent-hover:    #333333;
    --secondary-bg:    #f0f0f0;
    --secondary-hover: #e0e0e0;
    --danger:          #c0392b;
    --success:         #1a7a4a;
    --success-stroke:  #1a7a4a;
    --shadow:          0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.05);
    --radius:          14px;
    --radius-sm:       8px;
    --transition:      0.25s ease;
}

/* ============================================================
   Variáveis — Dark Mode (auto via sistema)
   ============================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:              #0c0c0c;
        --surface:         #1a1a1a;
        --border:          #2e2e2e;
        --text-primary:    #f0f0f0;
        --text-secondary:  #aaaaaa;
        --text-hint:       #666666;
        --accent:          #f0f0f0;
        --accent-fg:       #111111;
        --accent-hover:    #cccccc;
        --secondary-bg:    #252525;
        --secondary-hover: #333333;
        --danger:          #e05252;
        --success:         #34c77b;
        --success-stroke:  #34c77b;
        --shadow:          0 1px 3px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.3);
    }
}

/* ============================================================
   Variáveis — override manual via data-theme no <html>
   ============================================================ */
html[data-theme="dark"]:root {
    --bg:              #0c0c0c;
    --surface:         #1a1a1a;
    --border:          #2e2e2e;
    --text-primary:    #f0f0f0;
    --text-secondary:  #aaaaaa;
    --text-hint:       #666666;
    --accent:          #f0f0f0;
    --accent-fg:       #111111;
    --accent-hover:    #cccccc;
    --secondary-bg:    #252525;
    --secondary-hover: #333333;
    --danger:          #e05252;
    --success:         #34c77b;
    --success-stroke:  #34c77b;
    --shadow:          0 1px 3px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.3);
}

html[data-theme="light"]:root {
    --bg:              #f8f8f8;
    --surface:         #ffffff;
    --border:          #e4e4e4;
    --text-primary:    #111111;
    --text-secondary:  #666666;
    --text-hint:       #999999;
    --accent:          #111111;
    --accent-fg:       #ffffff;
    --accent-hover:    #333333;
    --secondary-bg:    #f0f0f0;
    --secondary-hover: #e0e0e0;
    --danger:          #c0392b;
    --success:         #1a7a4a;
    --success-stroke:  #1a7a4a;
    --shadow:          0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.05);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    line-height: 1.5;
    transition: background var(--transition), color var(--transition);
}

/* ============================================================
   Container principal
   ============================================================ */
.container {
    width: 100%;
    max-width: 420px;
    position: relative;
}

/* ============================================================
   Telas (screens) — gerenciadas via JS adicionando .active
   ============================================================ */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition), transform var(--transition);
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Card
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow);
}

.card-center {
    text-align: center;
}

/* ============================================================
   Header icon
   ============================================================ */
.header-icon {
    width: 44px;
    height: 44px;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.header-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================================
   Tipografia
   ============================================================ */
.title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
}

/* ============================================================
   Input de valor
   ============================================================ */
.input-group {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: border-color var(--transition);
    overflow: hidden;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.input-prefix {
    padding: 0.75rem 0.875rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-right: 1.5px solid var(--border);
    background: var(--surface);
    user-select: none;
}

input#amount {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    /* Remove spinners */
    -moz-appearance: textfield;
}

input#amount::-webkit-inner-spin-button,
input#amount::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-hint {
    font-size: 0.8125rem;
    color: var(--text-hint);
    margin-top: 0.375rem;
}

.input-error {
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 0.375rem;
    min-height: 1rem;
}

/* ============================================================
   Botões
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8125rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s ease, opacity var(--transition);
    width: 100%;
    letter-spacing: -0.01em;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
}

.btn-icon {
    gap: 0.5rem;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================================
   Loading dots
   ============================================================ */
.loading-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: dot-bounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* ============================================================
   QR Code
   ============================================================ */
.qr-wrapper {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.qr-image {
    width: 220px;
    height: 220px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    padding: 10px;
    /* Força fundo branco independente do tema */
    box-shadow: 0 0 0 1px var(--border);
}

/* ============================================================
   Valor exibido
   ============================================================ */
.amount-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.amount-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.amount-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ============================================================
   Timer
   ============================================================ */
.timer-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--bg);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.timer-icon {
    width: 15px;
    height: 15px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.timer {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    transition: color 0.5s ease;
}

.timer.urgent {
    color: var(--danger);
    animation: timer-pulse 1s infinite;
}

.timer-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ============================================================
   PIX Copia e Cola
   ============================================================ */
.pix-copy-wrapper {
    margin-bottom: 1.5rem;
}

.pix-copy-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.pix-copy-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.pix-string {
    flex: 1;
    font-size: 0.6875rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Courier New', Courier, monospace;
    display: block;
    min-width: 0;
}

.btn-icon.btn-secondary {
    width: auto;
    flex-shrink: 0;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
}

/* ============================================================
   Aguardando confirmação
   ============================================================ */
.waiting-text {
    font-size: 0.8125rem;
    color: var(--text-hint);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.dot-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-hint);
    display: inline-block;
    animation: dot-bounce 1.5s infinite ease-in-out;
}

/* ============================================================
   Ícone de sucesso (SVG animado)
   ============================================================ */
.success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
}

.success-icon svg {
    width: 100%;
    height: 100%;
}

.success-circle {
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-miterlimit: 10;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-check {
    stroke: var(--success);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

.success-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
}

/* ============================================================
   Ícone de expirado
   ============================================================ */
.expired-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    color: var(--text-secondary);
}

.expired-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================================
   Botão de tema
   ============================================================ */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    z-index: 100;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--secondary-bg);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================================
   Responsividade
   ============================================================ */
@media (max-width: 480px) {
    body {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .card {
        padding: 1.5rem 1.25rem;
    }

    .qr-image {
        width: 190px;
        height: 190px;
    }
}
