/* ==========================================================================
   1. Variáveis Globais (Design Tokens)
   ========================================================================== */
:root {
    /* Cores */
    --color-primary: #FFD100;
    --color-primary-dark: #F0C100;
    --color-secondary: #7AC91F;
    --color-text-dark: #1C1C1C;
    --color-text-normal: #333333;
    --color-text-light: #555555;
    --color-text-placeholder: #999999;
    --color-background: #ffffff;
    --color-background-desktop: #f0f2f5;
    --color-surface: #F5F5F5;
    --color-surface-alt: #E9ECEF;
    --color-surface-alt-hover: #DCDFE3;
    --color-border: #E0E0E0;
    --color-error: red;
    --color-link: #007bff;
    --color-link-hover: #0056b3;
    --color-failure: #dc3545; /* Cor para o modal de falha */
    --color-failure-text: #ffffff;


    /* Tipografia */
    --font-family-base: Arial, sans-serif;
    --font-size-base: 1rem; /* 16px */
    --font-weight-normal: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Espaçamento e Raios */
    --border-radius-pill: 34px;
    --border-radius-card: 20px;
    --border-radius-modal: 15px;
    --border-radius-round: 50%;
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
}

/* ==========================================================================
   2. Reset Básico e Estilos Globais
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    height: 100%;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--color-background);
    height: 100%;
    overflow: hidden; /* Scroll será por view */
}

/* ==========================================================================
   3. Classes Utilitárias
   ========================================================================== */
.not-select {
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    user-select: none;
}
.validation-error-msg, .camera-error-msg { /* Added .camera-error-msg */
    color: var(--color-error);
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px; /* Adicionado para espaçamento */
    font-size: 0.875rem;
    width: 100%; /* Garantir que ocupe a largura */
}
.loading-placeholder, .error-placeholder { /* For select loading/error states */
    font-style: italic;
    color: var(--color-text-placeholder);
}

/* ==========================================================================
   4. Layout Principal e Views
   ========================================================================== */
.auth-container {
    background-color: var(--color-background);
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.view-section {
    width: 100%;
    display: none;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}
.view-section.active-view {
    display: flex;
}

/* ==========================================================================
   5. Componentes
   ========================================================================== */

/* --- Header --- */
.auth-header {
    background-color: var(--color-primary);
    padding: 25px var(--spacing-md) 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    flex-shrink: 0; /* Prevent header from shrinking */
}
.logo-image, .modal-logo-image { /* Combined for shared properties */
    width: 110px;
    height: 110px;
    margin-bottom: var(--spacing-md);
    object-fit: contain;
}
.logo-text-fallback {
    width: 110px; height: 110px;
    margin-bottom: var(--spacing-md);
    background-color: var(--color-surface-alt);
    border-radius: var(--border-radius-round);
    display: none; /* Shown via JS */
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.75rem;
}
.welcome-text {
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-dark);
    margin-top: 5px;
}
.font-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

/* --- Botões (Base + Modificadores) --- */
.btn {
    padding: 14px;
    border: none;
    border-radius: var(--border-radius-pill);
    font-size: 0.9375rem;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, opacity 0.2s ease-in-out;
    display: inline-block; /* Allows width, margin, etc. */
    width: 100%; /* Default to full width, can be overridden */
}
.btn:disabled { /* Estilo para botões desabilitados */
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}
.btn--primary {
    background-color: var(--color-primary);
    color: var(--color-text-dark);
}
.btn--primary:hover:not(:disabled) {
    background-color: var(--color-primary-dark);
}
.btn--secondary {
    background-color: var(--color-surface-alt);
    color: #4F4F4F; /* Specific color from original .login-btn */
}
.btn--secondary:hover:not(:disabled) {
    background-color: var(--color-surface-alt-hover);
}
.btn--danger { /* Para botões de ação de falha/erro */
    background-color: var(--color-failure);
    color: var(--color-failure-text);
}
.btn--danger:hover:not(:disabled) {
    background-color: color-mix(in srgb, var(--color-failure) 85%, black);
}
.btn--slim {
    padding: 10px 20px;
    font-size: 0.9rem;
}
.btn--main-action { /* For centered buttons with max-width */
    width: 80%;
    max-width: 300px;
    display: block; /* To enable auto margins */
    margin-left: auto;
    margin-right: auto;
}
.btn--bottom { /* Pushes button to the bottom of a flex container */
    margin-top: auto;
    margin-bottom: var(--spacing-md);
}
.btn--back {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    align-self: flex-start;
    margin-bottom: var(--spacing-md);
    width: auto; /* Back button shouldn't be full width by default */
}
.btn--back svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}
.btn.font-button { /* Specific style for font control buttons */
    background-color: var(--color-background);
    color: var(--color-text-normal);
    border: 1px solid #CCCCCC; /* Specific border */
    padding: 5px 10px;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-bold); /* Ensure boldness */
    line-height: 1;
    min-width: 30px;
    width: auto; /* Override .btn width: 100% */
}
.btn.font-button:hover:not(:disabled) {
    background-color: #f0f0f0; /* Specific hover */
}

/* --- Formulários --- */
.auth-form-section {
    padding: var(--spacing-lg);
    background-color: var(--color-background);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex-grow: 1;
}
.auth-form-section > form { /* Specifically targets the form in loginView */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    justify-content: center;
}
.auth-form-section > .btn--main-action { /* Targets .signup-btn-main in loginView */
    margin-top: auto; /* Pushes to bottom */
    padding-top: 15px; /* Original spacing */
}
.auth-form-section > .signup-prompt { /* Targets .signup-prompt in loginView */
    margin-bottom: 10px; /* Original spacing */
}
.form-title { /* Replaces .auth-form-section h2 */
    font-size: 1.125rem;
    color: var(--color-text-normal);
    margin-bottom: 25px;
    font-weight: var(--font-weight-semibold);
    text-align: center;
}
.input-field, .select-field {
    width: 100%;
    padding: 14px var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-pill);
    background-color: var(--color-surface);
    font-size: 0.9375rem;
    color: var(--color-text-normal);
    -webkit-appearance: none; /* Remove default styling in Safari/Chrome */
    -moz-appearance: none; /* Remove default styling in Firefox */
    appearance: none; /* Remove default styling */
}
.input-field::placeholder {
    color: var(--color-text-placeholder);
}
.input-field:focus, .select-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 30%, transparent);
}
.select-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23333'%3E%3Cpath fill-rule='evenodd' d='M4.22 6.03a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 1 0-1.06-1.06L8 8.94 4.22 6.03Z' clip-rule='evenodd' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem; /* Space for the arrow */
}
.remember-me-container {
    width: 100%;
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    padding-left: 10px;
    font-size: 0.875rem;
    color: var(--color-text-light);
}
.remember-me-container input[type="checkbox"] {
    margin-right: var(--spacing-xs);
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    vertical-align: middle;
    cursor: pointer;
}
.remember-me-container label {
    vertical-align: middle;
    cursor: pointer;
}
.signup-prompt {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: 10px;
    text-align: center;
}

/* --- Conteúdo de Páginas Internas (Registration, Selfie, etc.) --- */
.registration-top-bar { /* Specific for these views */
    height: 10px;
    background-color: var(--color-primary);
    width: 100%;
    flex-shrink: 0;
}
.content-area { /* Common padding and flex for inner views */
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
}
/* Ensure direct children h2, .subtitle, .btn--back align left */
.content-area > h2,
.content-area > .subtitle,
.content-area > .btn--back {
    align-self: flex-start;
}
.content-area h2 { /* Different from .form-title */
    font-size: 1.5rem;
    color: var(--color-text-normal);
    margin-bottom: var(--spacing-xs);
    font-weight: var(--font-weight-semibold);
    text-align: left;
    width: 100%;
}
.content-area .subtitle {
    font-size: 0.95rem;
    color: var(--color-text-light);
    margin-bottom: var(--spacing-md);
    text-align: left;
    width: 100%;
}
/* Forms inside content areas */
.content-area form {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    align-items: center; /* Center form content like buttons */
}
.content-area form > .input-field,
.content-area form > .select-field {
    align-self: stretch; /* Make inputs full width */
    margin-bottom: 18px;
}


/* --- Componentes de Selfie e Instruções --- */
.selfie-icon { /* Replaces #selfieScanIcon for styling */
    width: 100px;
    height: 100px;
}
.selfie-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0 25px 0;
    width: 100%;
}
#selfieFormContent, #selfieCaptureContent { /* IDs kept for JS targeting if complex */
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    align-items: center;
}
#selfieFormContent > .instruction-item {
    align-self: stretch;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 18px;
    width: 100%;
}
.instruction-number {
    background-color: var(--color-secondary);
    color: var(--color-background); /* White */
    font-size: 0.9rem;
    font-weight: var(--font-weight-bold);
    border-radius: var(--border-radius-round);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.instruction-content {
    display: flex;
    flex-direction: column;
}
.instruction-title {
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-normal);
    margin-bottom: 4px;
}
.instruction-text {
    font-size: 0.875rem;
    color: var(--color-text-light);
    line-height: 1.4;
}
.selfie-image-placeholder-oval {
    width: 200px; /* Fixed width */
    height: 280px; /* Fixed height to create oval */
    border-radius: 140px / 100px; /* Elliptical border radius */
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 10px auto 20px; /* Center it */
    border: 3px solid var(--color-border);
    position: relative; /* For positioning video/img inside */
}
.selfie-image-placeholder-oval video, /* Video stream */
.selfie-preview-image { /* Captured image preview */
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the area, might crop */
    position: absolute;
    top: 0;
    left: 0;
}
.selfie-image-placeholder-oval video {
    transform: scaleX(-1); /* Mirror front camera */
}

#selfieOvalPlaceholderText { /* ID kept for JS */
    color: var(--color-background); /* White */
    z-index: 1; /* Above video/image if they are absolutely positioned */
}
.capture-status-text {
    font-size: 1.125rem;
    color: var(--color-text-normal);
    font-weight: var(--font-weight-semibold);
    margin-top: 10px;
    margin-bottom: 10px;
    text-align: center;
}
#viewTermsLink { /* ID kept for JS, styled as a link */
    font-size: 0.875rem;
    color: var(--color-link);
    text-decoration: underline;
    cursor: pointer;
    margin-bottom: 15px;
    text-align: center;
    display: none; /* Controlled by JS */
}
#viewTermsLink:hover {
    color: var(--color-link-hover);
}

/* --- Modais --- */
.modal-overlay {
    position: fixed;
    inset: 0; /* shorthand for top, right, bottom, left = 0 */
    background-color: rgb(0 0 0 / 0.6); /* Modern rgba */
    display: none; /* Shown via .open class */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--spacing-md);
}
.modal-overlay.open {
    display: flex;
}
.modal-content, .success-modal-content, .failure-modal-content { /* Shared styles */
    background-color: var(--color-background);
    padding: 25px;
    border-radius: var(--border-radius-modal);
    box-shadow: 0 5px 15px rgb(0 0 0 / 0.3);
    width: 90%;
    max-width: 360px;
    text-align: left;
}
.modal-content h3 {
    font-size: 1.3rem;
    color: var(--color-text-normal);
    margin-bottom: 15px;
    font-weight: var(--font-weight-semibold);
}
.modal-content p {
    font-size: 0.9rem;
    color: var(--color-text-light);
    line-height: 1.5;
    margin-bottom: 25px;
}
.modal-content p a {
    color: var(--color-link);
    text-decoration: underline;
}
.modal-content p a:hover {
    color: var(--color-link-hover);
}
.modal-actions {
    display: flex;
    justify-content: space-between; /* Default for two buttons */
    gap: 10px;
}
.modal-actions.single-action { /* For modals with a single centered button */
    justify-content: center;
}

.modal-btn { /* Applies to buttons inside .modal-actions */
    flex-grow: 1; /* Make buttons share space equally */
}
.modal-actions.single-action .modal-btn {
    flex-grow: 0; /* Don't grow if single button */
    width: 60%; /* Or a fixed width, or btn--main-action style */
}


.success-modal-content, .failure-modal-content { /* Styles for specific modals */
    text-align: center;
    padding: var(--spacing-lg) 25px;
}
.success-modal-content .modal-logo-image,
.failure-modal-content .modal-logo-image {
    width: 80px;
    height: 80px;
    margin-bottom: var(--spacing-md);
}
.success-modal-content h3,
.failure-modal-content h3 {
    font-size: 1.75rem;
    color: var(--color-text-dark);
    font-weight: var(--font-weight-bold);
    margin-bottom: 10px;
}
.success-modal-content p,
.failure-modal-content p {
    font-size: 1rem;
    color: var(--color-text-light);
    line-height: 1.4;
    margin-bottom: 25px; /* Add margin for button spacing */
}
.failure-modal-content h3 {
    color: var(--color-failure); /* Specific color for failure heading */
}

/* ==========================================================================
   6. Media Query para Desktop
   ========================================================================== */
@media (min-width: 768px) {
    body {
        background-color: var(--color-background-desktop);
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 40px var(--spacing-md);
        overflow: auto; /* Allow body scroll for desktop */
    }
    .auth-container {
        width: 100%;
        max-width: 400px;
        height: auto;
        min-height: 650px;
        max-height: 90vh; /* Prevent overly tall cards */
        border-radius: var(--border-radius-card);
        box-shadow: 0 6px 20px rgb(0 0 0 / 0.1);
    }
}
