/* Global Pesquisas — estilos mobile-first / app-like */

:root {
    --azul: #1c75bc;
    --azul-escuro: #135a93;
    --azul-claro: #5fc2e8;
    --bg-top: #6fc8ec;
    --bg-bottom: #2a8fd0;
    --card: #ffffff;
    --texto: #16324a;
    --texto-suave: #6b8299;
    --borda: #d8e3ec;
    --verde: #1ea672;
    --vermelho: #e23b4e;
    --laranja: #e8902b;
    --sombra: 0 10px 30px rgba(11, 58, 97, .22);
    --radius: 16px;
    --tap: 52px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100dvh;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--texto);
    background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    background-attachment: fixed;
}

.app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 14px
             calc(20px + env(safe-area-inset-bottom)) 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100dvh;
}

/* ---- Card ---- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    overflow: hidden;
    animation: rise .45s ease both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.capa {
    margin: 0;
    line-height: 0;
    background: var(--azul-claro);
}
.capa img {
    width: 100%;
    height: auto;
    display: block;
}

.form-body { padding: 18px 16px 20px; }

/* ---- Campos ---- */
.field { margin-bottom: 14px; }

label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--azul-escuro);
}
.req { color: var(--vermelho); }

input, select {
    width: 100%;
    height: var(--tap);
    padding: 0 14px;
    font-size: 16px; /* evita zoom no iOS */
    color: var(--texto);
    background-color: #f7fafc;
    border: 1.5px solid var(--borda);
    border-radius: 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
input::placeholder { color: #9fb2c2; }
input:focus, select:focus {
    border-color: var(--azul);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(28, 117, 188, .15);
}

/* Select do operador: seta custom + cor de placeholder enquanto nada escolhido */
select {
    cursor: pointer;
    padding-right: 42px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b8299' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 13px;
}
select:invalid { color: #9fb2c2; }
select option { color: var(--texto); }

.hint {
    display: block;
    margin-top: 5px;
    font-size: 11.5px;
    color: #7f97a9;
}

.sep {
    border: none;
    border-top: 1px dashed var(--borda);
    margin: 16px 0;
}

/* ---- Controle do CPF com ícone de status ---- */
.control { position: relative; }
.control input { padding-right: 46px; }

.status {
    position: absolute;
    right: 12px;
    top: 50%;
    width: 22px;
    height: 22px;
    transform: translateY(-50%);
    border-radius: 50%;
    display: none;
}
.status.loading {
    display: block;
    border: 2.5px solid rgba(28,117,188,.25);
    border-top-color: var(--azul);
    animation: spin .7s linear infinite;
}
.status.ok, .status.err {
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}
.status.ok  { background: var(--verde); }
.status.ok::after  { content: "✓"; }
.status.err { background: var(--vermelho); }
.status.err::after { content: "✕"; }

@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.msg {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
    font-weight: 600;
    min-height: 16px;
}
.msg.ok  { color: var(--verde); }
.msg.err { color: var(--vermelho); }
.msg.warn { color: var(--laranja); }

/* Borda colorida por estado no field do CPF */
#field-cpf.is-ok   input { border-color: var(--verde); }
#field-cpf.is-err  input { border-color: var(--vermelho); }
#field-cpf.is-warn input { border-color: var(--laranja); }

/* ---- Fieldset bloqueado ---- */
fieldset {
    border: none;
    margin: 0;
    padding: 0;
    transition: opacity .25s;
}
fieldset.locked { opacity: .45; }
fieldset[disabled] input { background: #eef2f5; cursor: not-allowed; }

.row { display: flex; gap: 10px; }
.col-num { flex: 0 0 34%; }
.col-bairro { flex: 1 1 auto; }

/* ---- Botão ---- */
.btn {
    position: relative;
    width: 100%;
    height: 56px;
    margin-top: 6px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--azul) 0%, var(--azul-escuro) 100%);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .3px;
    cursor: pointer;
    overflow: hidden;
    transition: transform .08s, box-shadow .2s, opacity .2s, filter .2s;
    box-shadow: 0 8px 18px rgba(28,117,188,.35);
}
.btn:active { transform: scale(.985); }
.btn:disabled {
    filter: grayscale(.4);
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-spinner, .btn-check { display: none; }

.btn.loading .btn-label { visibility: hidden; }
.btn.loading .btn-spinner {
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
    width: 24px; height: 24px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin2 .7s linear infinite;
}
@keyframes spin2 { to { transform: rotate(360deg); } }

.btn.done { background: linear-gradient(135deg, #1ea672, #138757); }
.btn.done .btn-label { visibility: hidden; }
.btn.done .btn-check {
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
    width: 30px; height: 30px;
    color: #fff;
    animation: pop .4s ease both;
}
@keyframes pop {
    0% { transform: scale(.3); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.rodape {
    text-align: center;
    color: rgba(255,255,255,.85);
    font-size: 12px;
    font-weight: 600;
    margin: 14px 0 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,.12);
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translate(-50%, 140%);
    max-width: 88vw;
    padding: 13px 18px;
    border-radius: 12px;
    background: #16324a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
    z-index: 50;
    text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok   { background: #138757; }
.toast.err  { background: #c32d3f; }

/* ---- Acessibilidade / motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ---- Telas muito pequenas ---- */
@media (max-width: 340px) {
    .form-body { padding: 14px 12px 16px; }
    .row { flex-direction: column; gap: 0; }
    .col-num { flex: none; }
}
