/* Reset básico e tipografia */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

/* Tokens de tema (roxo) */
:root {
    --accent-600: #7c3aed;
    --accent-500: #8b5cf6;
    --accent-100: #f3e8ff;
    --accent-700: #581c87;
}

/* Tema escuro (padrão) */
:root[data-theme="dark"] {
    --bg: #0f1020;
    --surface: #181828;
    --text: #e7e7ee;
    --muted: #a1a1b0;
    --border: #2c325e;
}

/* Tema claro */
:root[data-theme="light"] {
    --bg: #faf8ff;
    --surface: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e5e7eb;
}

/* Layout de página */
body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Cabeçalho */
header {
    background-color: var(--accent-600);
    color: #ffffff;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Ações no cabeçalho (ex.: toggle de tema) */
.header-actions {
    display: flex;
    gap: 8px;
}

/* Navegação do cabeçalho centralizada */
header .header-nav {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 24px;
}

.header-nav a {
    color: #ffffff;
    text-decoration: none;
    opacity: 0.9;
    padding: 8px 12px;           /* padroniza altura */
    border-radius: 999px;        /* mesmo formato do ativo */
    display: inline-flex;        /* alinha verticalmente o texto */
    align-items: center;
    justify-content: center;
    line-height: 1;              /* evita altura extra */
    border: 0;                   /* sem borda para não variar altura */
}

.header-nav a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

/* Link ativo como botão roxo escuro (sempre visível) */
header .header-nav a[aria-current="page"] {
    background: var(--accent-700);
    color: #ffffff;
    font-weight: 800;
    opacity: 1;
}

/* Botão fantasma para header sobre fundo colorido */
button.ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

button.ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #ffffff;
}

/* Container principal */
.container {
    width: 100%;
    max-width: 720px;
    margin: 24px auto;
    padding: 0 16px;
}

/* Home container mais largo para grid de 3 cards */
.container.home {
    max-width: 1100px;
}

/* Cartão do formulário */
.card {
    background: var(--surface);
    border: none;
    border-radius: 12px;
    padding: 5%;
    box-shadow: 0 4px 16px rgba(199, 199, 199, 0.03);
}

/* Hero (home) */
.hero {
    text-align: left;
    display: grid;
    gap: 24px;
}

.hero h1 {
    font-size: clamp(28px, 4vw, 40px);
}

.hero .lead {
    color: var(--muted);
    line-height: 1.7;
}

/* Grid de cards de features na home */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.feature-card {
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    display: grid;
    gap: 8px;
    border: 1px solid transparent;
}

.feature-card:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.feature-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-100);
    display: grid;
    place-items: center;
    margin: 0 auto;
}

.feature-card svg { width: 24px; height: 24px; fill: var(--accent-600); }
.feature-card h3 { text-align: center; }
.feature-card p { text-align: center; color: var(--muted); }

/* Ajustes extras para telas muito estreitas (ex.: 320px) */
@media (max-width: 360px) {
    .container.home { padding: 0 12px; }
    .hero { gap: 16px; }
    .feature-grid { grid-template-columns: 1fr; gap: 12px; }
    .feature-card { padding: 12px; }
    .feature-card .icon { width: 40px; height: 40px; }
}

.hero .actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* Campos e grid responsivo */
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

label {
    font-weight: 600;
    color: var(--muted);
}

/* Entradas e áreas de texto */
input[type="number"],
textarea {
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 20px;
    box-shadow: 2px 6px rgba(178, 85, 255, 0.034);
    outline: none;
    background: var(--surface);
    color: var(--text);
}

input[type="number"]:focus,
textarea:focus {
    border-color: var(--accent-500);
    box-shadow: 2px 6px rgba(178, 85, 255, 0.034);
}

/* Botões segmentados de modo */
.segmented {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.segmented button {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.segmented button:hover {
    border-color: var(--accent-500);
    color: var(--accent-600);
}

.segmented button.active {
    background: var(--accent-600);
    color: #ffffff;
    border-color: var(--accent-600);
}

/* Botões principais */
button {
    appearance: none;
    border: none;
    background: var(--accent-600);
    color: #ffffff;
    padding: 12px 14px;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.05s ease;
    box-shadow: 2px 6px rgba(178, 85, 255, 0.034);
    font-weight: 600;
}

/* Spinner overlay */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    display: none;
    z-index: 50;
    align-items: center;
    justify-content: center;
}
.spinner-overlay.active { display: flex; }
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Respeita preferencias de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

button:hover {
    background: var(--accent-500);
}

button:active {
    transform: translateY(1px);
}

.actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 8px 0 16px;
}

textarea[readonly] {
    background: var(--surface);
}

/* Mensagens de erro */
.error {
    color: #b91c1c;
    font-size: 14px;
    min-height: 20px;
}

/* Rodapé */
.footer {
    margin-top: auto;
    background-color: var(--accent-600);
    color: #ffffff;
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.06);
    padding: 16px;
    text-align: center;
}

/* Responsividade */
@media (max-width: 1024px) {
    .container.home { max-width: 920px; }
}

@media (max-width: 768px) {
    header { flex-direction: column; gap: 12px; padding: 16px; }
    header .header-nav {
        position: static;
        left: auto; top: auto; transform: none;
        justify-content: center; flex-wrap: wrap; gap: 12px;
    }
    .container, .container.home { max-width: 100%; padding: 0 16px; }
}

@media (max-width: 600px) {
    .field-row { grid-template-columns: 1fr; }
}