/* ===== Tokens ===== */
:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-alt: #f9fafb;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, 0.12);
    --danger: #dc2626;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f19;
        --surface: #111827;
        --surface-alt: #0f1522;
        --border: #1f2937;
        --text: #f3f4f6;
        --text-muted: #9ca3af;
        --primary: #6366f1;
        --primary-hover: #818cf8;
        --primary-soft: rgba(99, 102, 241, 0.18);
        --danger: #f87171;
        --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    }
}

/* ===== Base ===== */
[hidden] {
    display: none !important;
}

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(1000px 500px at 50% -200px, var(--primary-soft), transparent),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Topbar ===== */
.topbar {
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
}

.badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 4px 10px;
    border-radius: 999px;
}

/* ===== Layout ===== */
.page {
    flex: 1;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 48px 20px 64px;
}

.hero {
    text-align: center;
    margin-bottom: 36px;
}

.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto;
}

.card {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel {
    padding: 32px;
}

.panel-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-preview {
    background: var(--surface-alt);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== Campos ===== */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

textarea,
select,
.color-input {
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
    padding: 12px 14px;
    resize: vertical;
    min-height: 92px;
}

select {
    height: 44px;
    padding: 0 12px;
    cursor: pointer;
}

textarea:focus,
select:focus,
.color-input:focus-within {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

.color-input {
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}

.color-input input[type="color"] {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border);
    border-radius: 6px;
}

.color-input span {
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.error {
    font-size: 0.8rem;
    color: var(--danger);
    min-height: 0;
}

.error:empty { display: none; }

/* ===== Botões ===== */
.btn {
    height: 46px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s, opacity 0.2s;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    flex: 1;
}

.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn.loading .spinner { display: inline-block; }

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

/* ===== Preview ===== */
.preview {
    flex: 1;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 20px;
}

.preview-empty {
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.preview-empty svg { opacity: 0.35; }

#qr-image {
    width: 100%;
    max-width: 240px;
    height: auto;
    aspect-ratio: 1;
    border-radius: 8px;
    animation: pop 0.35s ease-out;
}

@keyframes pop {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.actions {
    display: flex;
    gap: 12px;
}

/* ===== Features ===== */
.features {
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.features article {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.features h2 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.features p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    background: var(--text);
    color: var(--surface);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ===== Responsivo ===== */
@media (max-width: 820px) {
    .card { grid-template-columns: 1fr; }
    .panel-preview { border-left: none; border-top: 1px solid var(--border); }
    .features { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .page { padding: 32px 16px 48px; }
    .panel { padding: 22px; }
    .grid-2 { grid-template-columns: 1fr; }
    .badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
