/* ============================================
   FORMULÁRIO COM BOOTSTRAP - CSS CUSTOMIZADO
   ============================================
   Estilos que complementam o Bootstrap 5.3.0
   mantendo as cores e funcionalidades existentes.
*/

/* ============================================
   VARIÁVEIS CSS
   ============================================ */
.fw-bold {
    font-weight: bold !important;
    font-size: 25px !important;
}

/* ============================================
   VARIÁVEIS CSS
   ============================================ */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e0e0e0;
    --custom-link-color: #0d6efd;
    --custom-link-hover: #0a58ca;
    --warning-text-color: #856404;
    --warning-bg-color: #fff3cd;
    --warning-border-color: #ffc107;
    --info-text-color: #084298;
    --info-bg-color: #cfe2ff;
    --info-border-color: #0d6efd;
}

/* ============================================
   BODY E WRAPPER
   ============================================ */
body {
    background: var(--primary-gradient);
    /* Evita scroll vertical “permanente”: o padding entra no cálculo do viewport */
    min-height: calc(100vh - 40px);
    padding: 20px 10px;
    /* Hardening contra overflow horizontal causado por 1-2px (calc/neg margins/sticky) */
    overflow-x: hidden;
}

.wrapper {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* ============================================
   SISTEMA DE ETAPAS
   ============================================ */
.form-wrapper {
    display: none !important;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.form-wrapper.etapa-ativa {
    display: block !important;
    opacity: 1;
    transform: translateX(0);
    animation: slideIn 0.4s ease-out;
    min-height: 1px; /* Garantir que tenha altura mínima */
    visibility: visible !important;
    position: relative !important;
    left: auto !important;
}

.form-wrapper.etapa-ativa .container {
    min-height: 1px !important; /* Garantir que o container tenha altura mínima */
    height: auto !important; /* Permitir que o container cresça com o conteúdo */
}

.form-wrapper.etapa-ativa .card {
    min-height: 1px !important; /* Garantir que o card tenha altura mínima */
    height: auto !important; /* Permitir que o card cresça com o conteúdo */
}

.form-wrapper.etapa-ativa .card-body {
    min-height: 1px !important; /* Garantir que o card-body tenha altura mínima */
    height: auto !important; /* Permitir que o card-body cresça com o conteúdo */
}

.form-wrapper.etapa-ativa .row {
    display: flex !important;
    flex-wrap: wrap !important;
    min-height: 1px !important;
}

.form-wrapper.etapa-ativa .col-12 {
    display: block !important;
    min-height: 1px !important;
}

.form-wrapper.etapa-ativa .form-floating {
    display: block !important;
    min-height: 58px !important;
}

.form-wrapper.etapa-ativa .form-control {
    display: block !important;
    min-height: 58px !important;
}

.form-wrapper.etapa-saindo {
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   CARDS DO FORMULÁRIO
   ============================================ */
.form-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.form-card .card-body {
    padding: 25px;
}

/* ============================================
   LOGO
   ============================================ */
#logo {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

#logo img {
    max-width: 200px;
    height: auto;
}

/* ============================================
   INDICADOR DE PROGRESSO (STEPPER)
   ============================================ */
.progress-stepper {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    margin: -25px -25px 20px -25px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 12px 12px 0 0;
    box-sizing: border-box;
}

.progress-stepper-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
}

.progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Permitir que o label use a largura do step e consiga quebrar em 2 linhas */
    align-items: stretch;
    position: relative;
    min-width: 60px;
}

.progress-step::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 60%;
    width: 100%;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}

.progress-step:last-child::after {
    display: none;
}

.progress-step.completed::after {
    background: var(--success-color);
}

.progress-step.active::after {
    background: linear-gradient(to right, var(--success-color) 0%, var(--border-color) 100%);
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    /* Com align-items: stretch no pai, manter o círculo centralizado */
    align-self: center;
}

.progress-step.active .step-circle {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.progress-step.completed .step-circle {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.step-label {
    margin-top: 5px;
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    /* Quebrar em até 2 linhas (forçando quebra real) */
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    padding: 0 3px;
    white-space: normal !important;
    line-height: 1.15;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-height: calc(2 * 1.15em);
    overflow: hidden;
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

/* Ocultar títulos quando há stepper */
.form-wrapper.etapa-ativa h2 {
    display: none !important;
}

.form-wrapper.check-service.etapa-ativa h2 {
    display: block !important;
}

.form-wrapper.etapa-ativa .doc-progress {
    display: none !important;
}

.form-wrapper.check-service.etapa-ativa .doc-progress {
    display: block;
}

/* ============================================
   BOTÕES PERSONALIZADOS
   ============================================ */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    color: white;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

#btn-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   CHECKBOXES - MAIS CONTRASTE / ACESSIBILIDADE
   ============================================ */
.form-check-input {
    width: 1.25em;
    height: 1.25em;
    border: 2px solid #495057 !important;
    background-color: #fff;
}

.form-check-input:focus {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.form-check-input:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

/* ============================================
   LINKS CUSTOMIZADOS
   ============================================ */
a.custom-link {
    text-decoration: none;
    color: var(--custom-link-color);
    font-weight: 600;
    transition: color 0.2s ease;
    border-bottom: 2px solid transparent;
}

a.custom-link:hover {
    color: var(--custom-link-hover);
    border-bottom-color: var(--custom-link-hover);
    text-decoration: none;
}

a.custom-link:focus {
    outline: 2px solid var(--custom-link-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ============================================
   MENSAGENS DE VALIDAÇÃO
   ============================================ */
.message,
.message-cpf,
.message-user2,
.message-cep,
.message-address,
.sub-title p {
    font-size: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
    animation: fadeIn 0.3s ease-out;
    font-weight: 500;
    line-height: 1.5;
    min-height: 0;
}

/* Quando a mensagem está vazia, não ocupa espaço */
.message:empty,
.message-cpf:empty,
.message-user2:empty,
.message-cep:empty,
.message-address:empty,
.sub-title p:empty {
    display: none;
    margin: 0;
    padding: 0;
    min-height: 0;
}

/* Container de mensagem CEP - reduzir espaço quando vazio */
.sub-title:has(p:empty) {
    display: none;
    margin: 0;
    padding: 0;
}

/* Mensagens de aviso/erro - estilo alerta Bootstrap */
.message.warning,
.message-cpf.warning,
.message-user2.warning,
.message-cep.warning,
.message-address.warning,
.sub-title p.warning {
    background-color: var(--warning-bg-color);
    color: var(--warning-text-color);
    border: 1px solid var(--warning-border-color);
    border-left: 4px solid var(--warning-border-color);
}

/* Mensagens de erro - estilo alerta Bootstrap */
.message.error,
.message-cpf.error,
.message-user2.error,
.message-cep.error,
.message-address.error,
.sub-title p.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c2c7;
    border-left: 4px solid var(--error-color);
}

/* Mensagens de sucesso - estilo alerta Bootstrap */
.message.success,
.message-cpf.success,
.message-user2.success,
.message-cep.success,
.message-address.success,
.sub-title p.success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
    border-left: 4px solid var(--success-color);
}

/* Mensagens de informação - estilo alerta Bootstrap */
.message.info,
.message-cpf.info,
.message-user2.info,
.message-cep.info,
.message-address.info,
.sub-title p.info {
    background-color: var(--info-bg-color);
    color: var(--info-text-color);
    border: 1px solid var(--info-border-color);
    border-left: 4px solid var(--info-border-color);
}

/* Alertas de validação em etapas de documentos (JS: .doc-validation-alert)
   Padronizar tipografia com as mensagens do rodapé */
.doc-validation-alert {
    font-size: 20px !important;
    font-weight: 500;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 8px;
}

/* Descrição das etapas de documentos - centralizada e com menos espaço */
.doc-step-content .doc-description {
    margin-top: 0.25rem !important;
    margin-bottom: 0.25rem !important;
    padding: 0 !important;
}

.doc-step-content .doc-description p {
    text-align: center;
    margin: 0 !important;
    padding: 4px 12px !important;
    font-size: 20px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Estilos de mensagens já definidos acima */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   TOAST (MENSAGENS FLUTUANTES)
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    max-width: 90%;
    width: 100%;
    max-width: 400px;
}

/* ============================================
   OVERLAY "PROCESSANDO..." (UX)
   - Fica abaixo do toast (z-index: 10000)
   - Fica abaixo do modal de selfie (z-index: 99999)
   ============================================ */
#processingOverlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9000;
    pointer-events: all; /* bloqueia cliques “por baixo” */
}

#processingOverlay.is-visible {
    display: flex;
}

#processingOverlay .processing-card {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    padding: 18px 18px;
    text-align: center;
}

#processingOverlay .processing-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 10px;
    margin-bottom: 2px;
}

#processingOverlay .processing-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* Evita scroll “por baixo” enquanto o overlay estiver ativo */
body.processing {
    overflow: hidden;
    height: 100%;
}

@media (prefers-reduced-motion: reduce) {
    #processingOverlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

.toast {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease-out;
    border-left: 4px solid;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.error .toast-icon {
    color: var(--error-color);
}

.toast.warning .toast-icon {
    color: var(--warning-color);
}

.toast.info .toast-icon {
    color: var(--primary-color);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MENSAGENS DA ETAPA FINAL (ENVIO)
   ============================================ */
.sub-send {
    margin-top: 20px;
    margin-bottom: 20px;
}

.sub-send p,
#sub-send-msn {
    font-size: 16px;
    padding: 14px 18px;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
    animation: fadeIn 0.3s ease-out;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
}

/* Mensagens de sucesso na etapa final */
.sub-send p.success,
#sub-send-msn .success,
.sub-send p span.success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
    border-left: 4px solid var(--success-color);
}

/* Mensagens de aviso na etapa final */
.sub-send p.warning,
#sub-send-msn .warning,
.sub-send p span.warning {
    background-color: var(--warning-bg-color);
    color: var(--warning-text-color);
    border: 1px solid var(--warning-border-color);
    border-left: 4px solid var(--warning-border-color);
}

/* Mensagens de erro na etapa final */
.sub-send p.error,
#sub-send-msn .error,
.sub-send p span.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c2c7;
    border-left: 4px solid var(--error-color);
}

/* Mensagens de informação na etapa final */
.sub-send p.info,
#sub-send-msn .info,
.sub-send p span.info {
    background-color: var(--info-bg-color);
    color: var(--info-text-color);
    border: 1px solid var(--info-border-color);
    border-left: 4px solid var(--info-border-color);
}

/* ============================================
   CONTAINER DE ARQUIVOS
   ============================================ */
.files-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding: 5px;
}

.file-card {
    background: var(--primary-gradient);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideIn 0.3s ease-out;
    min-height: 50px;
}

.file-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.file-card-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-name {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

.file-remove-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    color: #fff;
}

.file-remove-btn:hover {
    background: rgba(255, 0, 0, 0.7);
    transform: scale(1.1);
}

.file-remove-btn i {
    font-size: 14px;
}

/* Scrollbar personalizada */
.files-container::-webkit-scrollbar {
    width: 6px;
}

.files-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.files-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.files-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ============================================
   INPUT FILE CUSTOMIZADO
   ============================================ */
/* Importante: evitar `display:none` em input file, pois pode bloquear o file picker em alguns browsers.
   Use esta classe para esconder visualmente mantendo o elemento “ativável” via click/label. */
.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
    pointer-events: none; /* evita clique direto; usamos label/JS */
}

input[type="file"]:not(#categoria_camera):not(#categoria_camera_upload) {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
}

input[type="file"]::file-selector-button {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
}

input[type="file"] {
    color: transparent !important;
    font-size: 0 !important;
}

/* ============================================
   MODAL DE CÂMERA
   ============================================ */
.modal {
    display: none;
    position: fixed;
    text-align: center;
    z-index: 99999 !important;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.show {
    display: block !important;
}

/* Evitar scroll da página “por baixo” quando o modal estiver aberto */
html.modal-open,
body.modal-open {
    overflow: hidden;
    height: 100%;
}

.modal-content {
    background-color: white;
    /* Dar “folga” no desktop para não encostar na borda inferior e não gerar scroll no fundo */
    margin: 24px auto;
    padding: 20px;
    width: 90%;
    max-width: 480px;
    text-align: center;
    border-radius: 20px;
    /* Desktop: altura consistente (evita mudar de tamanho ao reabrir / tirar outra) */
    height: min(760px, calc(100vh - 96px));
    max-height: min(760px, calc(100vh - 96px));
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Viewport dinâmico (corrige 100vh no mobile com barras do navegador) */
@supports (height: 100dvh) {
    .modal {
        height: 100dvh;
    }

    .modal-content {
        height: min(760px, calc(100dvh - 96px));
        max-height: min(760px, calc(100dvh - 96px));
    }
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    color: #333;
    z-index: 10001;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 14px auto;
    aspect-ratio: 3 / 4;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
}

.face-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 65%;
    height: 75%;
    border: 3px dashed rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Remover ícone de olho */
.face-guide::before {
    display: none;
}

#preview-image {
    width: 100%;
    max-width: 360px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
}

#validation-message {
    text-align: center;
    padding: 14px;
    margin: 12px 0;
    border-radius: 8px;
    font-size: 16px;
    display: block;
    min-height: 0;
    line-height: 1.6;
}

#validation-message strong {
    font-size: 18px;
    display: block;
    margin-bottom: 4px;
}

#validation-message small {
    font-size: 15px;
    display: block;
    margin-top: 0;
    line-height: 1.5;
}

#preview-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

#preview-buttons button {
    flex: 1;
    min-width: 120px;
    /* Evitar “botão maior” por quebra de linha */
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
}

/* Garantir que o modal-content tenha scroll adequado no mobile */
#capture-view,
#preview-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#preview-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#preview-container {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px auto;
    max-width: 360px;
    min-height: 0;
    max-height: 55vh;
    overflow: hidden;
}

#preview-image {
    max-height: 55vh;
    object-fit: contain;
}

/* Remover regras antigas que forçavam empilhamento/margens e deixavam botão com altura “estranha” */
#preview-buttons {
    margin-top: auto;
    padding-top: 12px;
    flex-shrink: 0;
}

/* ============================================
   CEP CONTAINER
   ============================================ */
.cep-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 0;
}

.cep-container .form-floating {
    flex: 1;
}

/* Reduzir espaço após container CEP quando mensagem está vazia */
.cep-container + .col-12:has(.sub-title p:empty) {
    display: none;
    margin: 0;
    padding: 0;
    min-height: 0;
}

/* Reduzir margem do primeiro campo após CEP na etapa de endereço */
.check-address .cep-container + .col-12 + .col-12:first-of-type {
    margin-top: 0;
}

/* Reduzir espaço quando mensagem CEP está vazia */
.check-address .col-12:has(.sub-title p.message-cep:empty) {
    display: none;
    margin: 0;
    padding: 0;
    min-height: 0;
}

/* ============================================
   RESPONSIVIDADE MOBILE
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 10px 5px;
        /* Padding total vertical = 20px */
        min-height: calc(100vh - 20px);
    }
    
    .wrapper {
        padding: 0;
    }
    
    .form-card .card-body {
        padding: 15px;
    }
    
    .progress-stepper {
        padding: 10px 12px;
        margin: -15px -12px 12px -12px;
    }
    
    .step-label {
        font-size: 8px;
        margin-top: 3px;
    }
    
    .step-circle {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .step-circle i {
        font-size: 12px;
    }
    
    .form-actions {
        margin-top: 15px;
        gap: 8px;
    }
    
    .toast-container {
        top: 10px;
        max-width: 95%;
    }
    
    #logo img {
        max-width: 150px;
    }
    
    .sub-title p {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        /* Preferir altura dinâmica (JS define --vvh com visualViewport/innerHeight) */
        height: calc(var(--vvh, 1vh) * 100);
        max-height: calc(var(--vvh, 1vh) * 100);
        margin: 0;
        padding: 15px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    .video-container {
        max-width: 100%;
        /* Evita que o vídeo/silhueta “engula” o espaço do botão em telas baixas */
        /* IMPORTANTE: limitar altura e largura juntos para não deformar a proporção (evita “silhueta circular”) */
        --selfie-available-h: clamp(260px, calc((var(--vvh, 1vh) * 100) - 320px), 520px);
        max-height: var(--selfie-available-h);
        max-width: min(100%, 360px, calc(var(--selfie-available-h) * 0.75));
        margin: 10px auto;
        flex-shrink: 0;
    }
    
    .close {
        font-size: 28px;
        top: 5px;
        right: 10px;
    }
    
    #capture-view h2,
    #preview-view h2 {
        font-size: 18px;
        margin: 10px 0;
    }
    
    #capture-view p {
        font-size: 12px;
        padding: 8px;
        margin: 10px 0;
    }
    
    #btn-capturar-foto {
        margin-top: 8px;
        padding: 12px;
    }

    #btn-switch-camera {
        padding: 12px;
    }

    /* Manter botão de captura sempre acessível acima da barra inferior */
    #btn-capturar-foto {
        position: sticky;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        z-index: 2;
    }
    
    #preview-buttons {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 15px 0;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        margin-top: auto;
        border-top: 1px solid #e0e0e0;
        flex-shrink: 0;
    }
    
    #preview-buttons button {
        padding: 12px;
        font-size: 14px;
        width: auto;
        margin-bottom: 0;
    }
    
    #preview-buttons button:last-child {
        margin-bottom: 0;
    }
    
    #preview-container {
        max-height: 300px;
        min-height: 150px;
    }
    
    #validation-message {
        margin: 15px 0;
        padding: 18px;
        font-size: 15px;
        min-height: 70px;
    }
    
    #validation-message strong {
        font-size: 17px;
        margin-bottom: 6px;
    }
    
    #validation-message small {
        font-size: 14px;
        margin-top: 6px;
    }
    
    .file-card {
        padding: 8px 10px;
        min-height: 40px;
    }
    
    .file-name {
        font-size: 13px;
    }
    
    .file-size {
        font-size: 11px;
    }
    
    .file-remove-btn {
        width: 28px;
        height: 28px;
    }
    
    .files-container {
        max-height: 200px;
    }
}

/* Prevenir zoom no iOS ao focar inputs */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select {
        font-size: 16px !important;
    }
}

/* ============================================
   ANIMAÇÕES E TRANSITIONS
   ============================================ */
* {
    -webkit-tap-highlight-color: transparent;
}

input, select, button {
    -webkit-tap-highlight-color: transparent;
}
