:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1f2a37;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #374151;
    --success: #166534;
    --error: #b91c1c;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    --app-bg: #e9e9e9;
    --app-bar: #2f3d57;
    --app-bar-text: #ffffff;
    --app-logo-bg: #efefef;
    --app-label: #737373;
    --app-back: #bdbdbd;
    --app-back-text: #ffffff;
    --app-confirm: #20b554;
    --app-confirm-hover: #199747;
    --home-flow-btn-radius: 20px;
}

body.theme-azul {
    --bg: #eef3fb;
    --app-bg: #e7edf7;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --app-bar: #2f3d57;
    --app-logo-bg: #f2f5fb;
    --app-label: #5f6f86;
    --app-back: #b5becc;
    --app-back-text: #ffffff;
    --app-confirm: #20b554;
    --app-confirm-hover: #199747;
}

body.theme-verde {
    --bg: #edf6ef;
    --app-bg: #e7f2e9;
    --surface: #ffffff;
    --text: #1f2d24;
    --muted: #5f7266;
    --primary: #15803d;
    --primary-hover: #166534;
    --app-bar: #14532d;
    --app-logo-bg: #edf5ee;
    --app-label: #4f6657;
    --app-back: #b7c3b9;
    --app-back-text: #ffffff;
    --app-confirm: #16a34a;
    --app-confirm-hover: #15803d;
}

body.theme-violeta {
    --bg: #f3effd;
    --app-bg: #eee8fb;
    --surface: #ffffff;
    --text: #2a2240;
    --muted: #6f6393;
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --app-bar: #312e81;
    --app-logo-bg: #f3effd;
    --app-label: #635989;
    --app-back: #bcb3d4;
    --app-back-text: #ffffff;
    --app-confirm: #8b5cf6;
    --app-confirm-hover: #7c3aed;
}

body.theme-grafite {
    --bg: #eff1f4;
    --app-bg: #e6e9ee;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #5b6473;
    --primary: #374151;
    --primary-hover: #1f2937;
    --app-bar: #111827;
    --app-logo-bg: #f1f3f6;
    --app-label: #5d6675;
    --app-back: #b6bfcb;
    --app-back-text: #ffffff;
    --app-confirm: #0ea5e9;
    --app-confirm-hover: #0284c7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

.container {
    width: min(100%, 1024px);
    margin: 0 auto;
    padding: 0 1rem;
}

.site-header,
.site-footer {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-footer {
    border-top: 1px solid var(--border);
    border-bottom: 0;
    margin-top: 2rem;
    padding: 1rem 0;
    color: var(--muted);
}

.site-footer-tagline {
    font-size: 0.82rem;
    line-height: 1.4;
}

.brand {
    margin: 0;
    padding: 1rem 0;
    font-size: 1.15rem;
}

.main-content {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

h2 {
    margin-top: 0;
    font-size: 1.25rem;
}

.muted {
    color: var(--muted);
}

.highlight {
    font-size: 1.1rem;
    font-weight: 700;
}

.form {
    display: grid;
    gap: 1rem;
}

.grid {
    display: grid;
    gap: 0.9rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

input,
select,
button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font-size: 1rem;
    background: #fff;
}

input:focus,
select:focus {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    border-color: var(--primary);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    font-weight: 600;
    border: 0;
    cursor: pointer;
}

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

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

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.card .btn {
    border-radius: var(--home-flow-btn-radius);
}

.alert {
    border-radius: 10px;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: var(--error);
    border: 1px solid #fca5a5;
}

.home-screen {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0 1rem;
}

.home-card {
    width: min(100%, 360px);
    min-height: 100dvh;
    background: var(--app-bg);
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.home-app-topbar,
.home-app-bottombar {
    min-height: 52px;
    background: var(--app-bar);
}

.home-app-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: max(env(safe-area-inset-top), 0px);
    color: var(--app-bar-text);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.2);
    z-index: 1;
}

.home-app-bottombar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.18);
}

.home-app-bottombar-text {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.02em;
}

.home-app-bottombar-year {
    font-variant-numeric: tabular-nums;
}

.home-body {
    flex: 1;
    display: grid;
    grid-template-rows: auto 1fr;
    align-items: stretch;
    padding: 1rem 1.1rem 1rem;
}

.home-logo-wrap {
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    min-height: 92px;
    display: grid;
    place-items: center;
    background: var(--app-logo-bg);
}

.home-logo {
    max-width: 100%;
    height: auto;
    display: block;
}

.home-logo-fallback {
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--primary);
    font-size: 1.55rem;
}

.home-logo.has-error {
    display: none;
}

.home-form {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    justify-self: center;
    align-self: center;
}

.home-label {
    color: var(--app-label);
    font-size: 0.94rem;
    margin-bottom: 0.35rem;
}

.home-select {
    border: 1px solid #9e9e9e;
    border-radius: var(--home-flow-btn-radius);
    min-height: 34px;
    background: #fff;
    padding: 0.35rem 0.5rem;
}

.home-actions {
    margin-top: 1.35rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 0;
}

.home-actions-back {
    margin-top: 0.8rem;
}

.home-btn-back,
.home-btn-confirm {
    border-radius: var(--home-flow-btn-radius);
    width: auto;
    min-width: 96px;
    min-height: 38px;
    padding: 0.55rem 0.9rem;
    color: var(--app-back-text);
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
}

.home-btn-back {
    background: var(--app-back);
}

.home-btn-confirm {
    background: var(--app-confirm);
}

.home-btn-confirm:hover {
    background: var(--app-confirm-hover);
}

.home-btn-option {
    min-width: 132px;
}

.reserva-timer-bar {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
    color: #713f12;
}

.reserva-timer-bar--resumo {
    padding: 0.6rem 0.9rem;
    line-height: 1.5;
    text-align: center;
    margin-bottom: 1rem;
}

.reserva-timer-bar strong {
    font-size: 1.05rem;
    color: #b45309;
}

.home-dates-list {
    margin-top: 0.5rem;
    max-height: 42dvh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
    padding-right: 0.2rem;
}

/* Data ou horário: só uma opção — botão centrado (evita ficar na coluna esquerda da grelha) */
.home-dates-list--single-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.home-dates-list--single-option .home-date-btn {
    width: auto;
    min-width: 7.5rem;
    max-width: min(100%, 12rem);
    padding-left: 1.15rem;
    padding-right: 1.15rem;
}

/* Tela de procedimentos: uma coluna e texto que pode quebrar linha */
.home-dates-list--single {
    grid-template-columns: 1fr;
    overflow-x: hidden;
}

.home-dates-list--single .home-date-btn.home-btn-confirm {
    white-space: normal;
    line-height: 1.35;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.home-date-btn {
    width: 100%;
    justify-content: center;
    border-radius: var(--home-flow-btn-radius);
}

.home-date-btn--reservado,
.home-date-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    filter: grayscale(40%);
}

.pedido-medico-upload {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 1rem;
    width: 100%;
}

.pedido-medico-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.pedido-medico-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 1.2rem 1rem;
    border: 2px dashed var(--primary, #2563eb);
    border-radius: 12px;
    background: var(--input-bg, #f0f6ff);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.pedido-medico-dropzone:active,
.pedido-medico-dropzone:focus-within {
    background: var(--primary-light, #dbeafe);
    border-color: var(--primary-dark, #1d4ed8);
}

.pedido-medico-dropzone-icon {
    font-size: 2rem;
    line-height: 1;
}

.pedido-medico-dropzone-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary, #2563eb);
}

.pedido-medico-dropzone-hint {
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
}

.pedido-medico-dropzone--selecionado {
    border-style: solid;
    background: #f0fdf4;
    border-color: #16a34a;
}

.pedido-medico-dropzone--selecionado .pedido-medico-dropzone-icon {
    font-size: 2rem;
}

.pedido-medico-dropzone--selecionado .pedido-medico-dropzone-title {
    color: #15803d;
}

.pedido-medico-arquivo-nome {
    font-size: 0.82rem;
    color: #15803d;
    font-weight: 600;
    text-align: center;
    word-break: break-all;
    margin: 0;
    min-height: 1.1em;
}

.paciente-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 1rem;
}

.paciente-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.paciente-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.paciente-required {
    color: #dc2626;
}

.paciente-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 10px;
    background: var(--input-bg, #fff);
    font-size: 0.97rem;
    color: var(--text);
    box-sizing: border-box;
}

.paciente-input:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.paciente-input--erro {
    border-color: #dc2626 !important;
}

.paciente-input--nome-upper {
    text-transform: uppercase;
}

.paciente-input--email-lower {
    text-transform: lowercase;
}

.paciente-cpf-erro {
    display: block;
    font-size: 0.82rem;
    color: #dc2626;
    margin-top: 0.25rem;
    line-height: 1.3;
    min-height: 1.25em;
}

.paciente-cpf-erro:empty {
    display: none;
}

.paciente-lgpd {
    width: 100%;
    margin: 0 0 1rem;
    padding: 0.75rem 0.85rem;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 10px;
}

.paciente-lgpd-label {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    cursor: pointer;
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--text);
    margin: 0;
}

.paciente-lgpd-check {
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.15rem;
    accent-color: var(--primary, #2563eb);
    cursor: pointer;
}

.paciente-lgpd-check:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

.paciente-lgpd-text {
    flex: 1;
}

.paciente-lgpd-link {
    color: var(--primary, #2563eb);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.paciente-lgpd-link:hover {
    color: var(--primary-hover, #1d4ed8);
}

.home-card--lgpd .lgpd-body {
    padding: 0 1rem 1.25rem;
    max-width: 42rem;
    margin: 0 auto;
}

.lgpd-titulo {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
    color: var(--text);
    text-align: center;
}

.lgpd-intro {
    font-size: 0.92rem;
    color: var(--muted);
    margin: 0 0 1.25rem;
    text-align: center;
    line-height: 1.5;
}

.lgpd-sections {
    text-align: left;
    margin-bottom: 1rem;
}

.lgpd-block {
    margin-bottom: 1rem;
}

.lgpd-subtitulo {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: var(--primary, #2563eb);
}

.lgpd-block p {
    font-size: 0.88rem;
    color: var(--text);
    margin: 0;
    line-height: 1.55;
}

.lgpd-rodape {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 1rem;
    line-height: 1.5;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.lgpd-actions {
    margin-top: 0.5rem;
}

.agend-paciente-resumo {
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.agend-resumo-card {
    width: 100%;
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.agend-resumo-linha {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0.65rem 1rem;
    gap: 0.2rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.agend-resumo-linha:last-child {
    border-bottom: none;
}

.agend-resumo-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted, #6b7280);
    letter-spacing: 0.02em;
}

.agend-resumo-valor {
    font-size: 0.93rem;
    color: var(--text);
    text-align: left;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.agend-paciente-resumo p {
    margin: 0.2rem 0;
    font-size: 0.93rem;
}

.age-existente-aviso {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 1rem;
    color: #92400e;
    margin-bottom: 1rem;
    width: 100%;
}

.age-existente-icone {
    font-size: 1.3rem;
}

.age-existente-detalhes {
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    width: 100%;
}

.age-existente-detalhes p {
    margin: 0.25rem 0;
    font-size: 0.95rem;
}

.age-existente-label {
    font-weight: 600;
}

.age-existente-instrucao {
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-align: center;
    width: 100%;
}

.age-existente-acoes {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

.age-existente-btn {
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: var(--home-flow-btn-radius);
    font-size: 0.95rem;
    line-height: 1.4;
    text-decoration: none;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

button.age-existente-btn {
    border: none;
    font: inherit;
    cursor: pointer;
}

.age-existente-btn--novo {
    background: var(--primary, #16a34a);
    color: #fff;
}

.age-existente-btn--wpp {
    background: #25d366;
    color: #fff;
}

.age-existente-btn--cancelar {
    background: #dc2626;
    color: #fff;
}

.age-existente-wpp-icon {
    margin-right: 0.3rem;
}

body.page-home {
    background: var(--app-bg);
    font-size: 15px;
}

body.page-home .container {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

body.page-home .main-content {
    padding: 0;
}

body.page-home .site-footer {
    margin-top: 0;
}

body.page-home .home-screen {
    padding: 0;
}

body.page-home .home-card {
    width: 100%;
    min-height: 100dvh;
}

@media (min-width: 768px) {
    .brand {
        font-size: 1.4rem;
    }

    .card {
        padding: 1.5rem;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions {
        flex-direction: row;
    }

    .actions .btn,
    .actions button {
        width: auto;
        min-width: 180px;
    }

    .home-card {
        min-height: 100dvh;
    }

    body.page-home .home-card {
        min-height: 100dvh;
    }
}

/* ─── Tela de sucesso ─── */
.home-card--sucesso {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Rodapé deve ocupar toda a largura (align-items: center encolhe filhos à largura intrínseca) */
.home-card--sucesso .home-app-bottombar {
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
}

.sucesso-mensagem {
    margin-top: 1.5rem;
}

.sucesso-titulo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary, #1a56db);
    line-height: 1.4;
    margin-bottom: 1rem;
}

.sucesso-subtitulo {
    font-size: 1rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 0.75rem;
}

.sucesso-agradecimento {
    font-size: 1rem;
    color: var(--text, #1e293b);
}
