* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Safe area para dispositivos com notch */
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --safe-left: env(safe-area-inset-left, 0);
    --safe-right: env(safe-area-inset-right, 0);
    /* Cores do tema Coruja - baseadas no logotipo */
    --gold: #FFD700;
    --gold-dark: #D4AF37;
    --orange: #FF6B35;
    --orange-dark: #E85A2B;
    --red: #DC143C;
    --red-dark: #B22222;
    
    /* Cores de fundo escuras */
    --bg-primary: #1A1C20;
    --bg-secondary: #20232B;
    --bg-card: #272B33;
    --bg-input: #2A2E38;
    
    /* Cores de texto */
    --text-primary: #FFFFFF;
    --text-secondary: #B8BCC8;
    --text-hint: #8A8D98;
    
    /* Cores de borda */
    --border-color: #3A3F4A;
    --border-focus: var(--orange);
    
    /* Gradientes */
    --gradient-gold: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    --gradient-orange: linear-gradient(135deg, #FF6B35 0%, #E85A2B 100%);
    --gradient-red: linear-gradient(135deg, #DC143C 0%, #B22222 100%);
    --gradient-bg: radial-gradient(ellipse at center, #252830 0%, #1A1C20 100%);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gradient-bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-left: max(20px, var(--safe-left));
    padding-right: max(20px, var(--safe-right));
    padding-top: max(20px, var(--safe-top));
    padding-bottom: max(20px, var(--safe-bottom));
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Cartões no fundo em movimento (igual telaconsultavel: cardDrift = deriva diagonal + fade) */
.auth-floating-cards {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.auth-floating-cards .floating-card {
    position: absolute;
    width: clamp(180px, 22vw, 300px);
    height: clamp(110px, 13vw, 180px);
    left: 0;
    border-radius: 20px;
    border: 1px solid rgba(255, 107, 53, 0.35);
    background: linear-gradient(135deg, rgba(39, 43, 51, 0.94), rgba(255, 107, 53, 0.25));
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.auth-floating-cards .floating-card::before {
    content: "";
    position: absolute;
    top: 18%;
    left: 12%;
    width: 25%;
    height: 14%;
    border-radius: 5px;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
}

.auth-floating-cards .floating-card::after {
    content: "";
    position: absolute;
    bottom: 18%;
    right: -40%;
    width: 80%;
    height: 6%;
    border-radius: 50px;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.25), transparent);
}

/* Keyframes do telaconsultavel: deriva diagonal com opacity entrando/saindo */
@keyframes cardDriftA {
    0% {
        transform: translate(0%, 40%) rotate(-8deg) scale(0.95);
        opacity: 0;
    }
    8% { opacity: 0.5; }
    45% { opacity: 0.6; }
    70% { opacity: 0.4; }
    100% {
        transform: translate(60%, -35%) rotate(6deg) scale(1.05);
        opacity: 0;
    }
}

@keyframes cardDriftB {
    0% {
        transform: translate(50%, 60%) rotate(12deg) scale(0.9);
        opacity: 0;
    }
    12% { opacity: 0.35; }
    50% { opacity: 0.5; }
    78% { opacity: 0.3; }
    100% {
        transform: translate(0%, -25%) rotate(-4deg) scale(1.08);
        opacity: 0;
    }
}

@keyframes cardDriftC {
    0% {
        transform: translate(0%, 50%) rotate(-18deg) scale(0.85);
        opacity: 0;
    }
    10% { opacity: 0.45; }
    55% { opacity: 0.55; }
    82% { opacity: 0.35; }
    100% {
        transform: translate(50%, -15%) rotate(2deg) scale(1.05);
        opacity: 0;
    }
}

.auth-floating-cards .floating-card.card-1 {
    top: 10%;
    left: 0%;
    animation: cardDriftA 18s linear infinite;
}

.auth-floating-cards .floating-card.card-2 {
    bottom: 5%;
    right: 0%;
    left: auto;
    animation: cardDriftB 22s linear infinite;
}

.auth-floating-cards .floating-card.card-2::before {
    top: 20%;
    left: 18%;
    width: 22%;
    background: linear-gradient(120deg, rgba(255, 215, 0, 0.3), rgba(255, 107, 53, 0.25));
}

.auth-floating-cards .floating-card.card-3 {
    bottom: 5%;
    left: 25%;
    border-color: rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, rgba(39, 43, 51, 0.92), rgba(255, 215, 0, 0.2));
    animation: cardDriftC 26s linear infinite;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--orange);
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* Tabs (dentro do modal) */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    position: relative;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    border: 2px solid var(--orange);
    background: var(--bg-input);
    color: var(--orange);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    position: relative;
    z-index: 1;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tab:first-child {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

.tab:last-child {
    border-radius: 0 8px 8px 0;
    border-left: 1px solid var(--orange);
}

.tab:hover:not(.active) {
    background: rgba(255, 107, 53, 0.12);
}

.tab.active {
    background: var(--gradient-orange);
    color: var(--text-primary);
    border-color: var(--orange);
    z-index: 2;
}

.tab.active:first-child {
    border-right: 2px solid var(--orange);
    border-radius: 8px 0 0 8px;
}

.tab.active:last-child {
    border-left: 2px solid var(--orange);
    border-radius: 0 8px 8px 0;
}

/* Card Container - para animação de virar página */
.card-wrapper {
    perspective: 1800px;
    perspective-origin: center center;
}

/* Card - altura fixa para não mudar ao virar entre login e cadastro */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px 30px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    position: relative;
    height: 560px;
    min-height: 560px;
    overflow-y: auto;
    overflow-x: hidden;
    transform-style: preserve-3d;
    transform-origin: center center;
}

/* Animação: virar página para a DIREITA (ENTRAR → CADASTRAR) */
.card.flip-right {
    animation: cardFlipRight 0.6s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}

@keyframes cardFlipRight {
    0% {
        transform: rotateY(0deg) scale(1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
    25% {
        transform: rotateY(45deg) scale(0.98);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
    50% {
        transform: rotateY(90deg) scale(0.96);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
    75% {
        transform: rotateY(45deg) scale(0.98);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
    100% {
        transform: rotateY(0deg) scale(1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
}

/* Animação: virar página para a ESQUERDA (CADASTRAR → ENTRAR) */
.card.flip-left {
    animation: cardFlipLeft 0.6s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}

@keyframes cardFlipLeft {
    0% {
        transform: rotateY(0deg) scale(1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
    25% {
        transform: rotateY(-45deg) scale(0.98);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
    50% {
        transform: rotateY(-90deg) scale(0.96);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
    75% {
        transform: rotateY(-45deg) scale(0.98);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
    100% {
        transform: rotateY(0deg) scale(1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
}

/* Form */
.form {
    display: none;
    position: relative;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease 0.15s;
}

.form.active {
    display: block;
    opacity: 1;
}

.form.flipping-out {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.form-group {
    margin-bottom: 24px;
}

/* Linha com dois campos (SENHA e CONFIRMAR lado a lado) */
.form-row {
    display: flex;
    gap: 14px;
}

.form-row-two .form-group {
    flex: 1;
    margin-bottom: 24px;
}

/* Aviso ao lado do label (ex: telefone) */
.input-hint-warning {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--orange);
    margin-bottom: 8px;
}

.input-hint-warning .icon-warning {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--gold);
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px; /* >= 16px evita zoom no iOS ao focar */
    transition: all 0.3s ease;
    min-height: 48px; /* touch-friendly */
}

.input-wrapper input::placeholder {
    color: var(--text-hint);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.input-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-hint);
    margin-top: 6px;
}

/* Captcha */
.captcha-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-question {
    flex: 0 0 auto;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.captcha-input {
    flex: 1;
}

.captcha-refresh {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.captcha-refresh:hover {
    background: var(--bg-card);
    border-color: var(--orange);
    color: var(--orange);
    transform: rotate(180deg);
}

/* ReCAPTCHA style verification - tema Coruja */
.recaptcha-box {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.3s ease, background 0.3s ease;
    user-select: none;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.recaptcha-box:hover {
    border-color: var(--orange);
    background: rgba(255, 107, 53, 0.05);
}

.recaptcha-box.verified {
    border-color: var(--orange);
    background: rgba(255, 107, 53, 0.08);
    cursor: default;
}

.recaptcha-box.loading {
    pointer-events: none;
}

.recaptcha-checkbox {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.recaptcha-box:hover .recaptcha-checkbox {
    border-color: var(--orange);
}

.recaptcha-checkbox-inner {
    display: none;
}

.recaptcha-loading {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--orange);
}

.recaptcha-loading .recaptcha-spinner {
    width: 20px;
    height: 20px;
    animation: recaptchaSpin 0.8s linear infinite;
}

@keyframes recaptchaSpin {
    to { transform: rotate(360deg); }
}

.recaptcha-check {
    display: none;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
}

/* Estados: loading */
.recaptcha-box.loading .recaptcha-checkbox {
    border-color: var(--orange);
    background: rgba(255, 107, 53, 0.15);
}

.recaptcha-box.loading .recaptcha-loading {
    display: flex;
}

/* Estados: verified */
.recaptcha-box.verified .recaptcha-checkbox {
    border-color: var(--orange);
    background: var(--gradient-orange);
}

.recaptcha-box.verified .recaptcha-loading {
    display: none;
}

.recaptcha-box.verified .recaptcha-check {
    display: block;
}

.recaptcha-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.recaptcha-box.verified .recaptcha-text {
    color: var(--text-primary);
}

/* Botão desabilitado até verificação */
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.captcha-refresh svg {
    width: 18px;
    height: 18px;
}

/* Button */
.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--gradient-orange);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    min-height: 50px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Error Message */
.error-message {
    margin-top: 15px;
    padding: 12px;
    background: rgba(220, 20, 60, 0.1);
    border: 1px solid var(--red);
    border-radius: 8px;
    color: var(--red);
    font-size: 0.85rem;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ========== RESPONSIVE: Desktop, Tablet, Mobile ========== */

/* Tablet */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        padding: 0 16px;
    }
    
    .header {
        margin-bottom: 24px;
    }
    
    .logo {
        font-size: 3rem;
        letter-spacing: 3px;
    }
    
    .subtitle {
        font-size: 1.1rem;
        letter-spacing: 3px;
    }
    
    .card {
        height: 540px;
        min-height: 540px;
        padding: 24px 24px 20px;
    }
    
    .tab {
        padding: 14px 16px;
        font-size: 0.9rem;
        min-height: 48px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .btn-primary {
        min-height: 50px;
        padding: 16px;
        font-size: 1rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body {
        padding: 16px;
        padding-left: max(16px, var(--safe-left));
        padding-right: max(16px, var(--safe-right));
        padding-top: max(16px, var(--safe-top));
        padding-bottom: max(16px, var(--safe-bottom));
        align-items: center;
        justify-content: center;
    }
    
    .container {
        max-width: 100%;
        padding: 0 8px;
        margin: 0 auto;
    }
    
    .header {
        margin-bottom: 18px;
    }
    
    .logo {
        font-size: 2.25rem;
        letter-spacing: 2px;
    }
    
    .subtitle {
        font-size: 1rem;
        letter-spacing: 2px;
    }
    
    .card-wrapper {
        width: 100%;
    }
    
    .card {
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
        padding: 20px 16px 16px;
        padding-left: max(16px, var(--safe-left));
        padding-right: max(16px, var(--safe-right));
        padding-bottom: max(16px, var(--safe-bottom));
        border-radius: 12px;
    }
    
    .tabs {
        margin-bottom: 20px;
    }
    
    .tab {
        padding: 14px 12px;
        font-size: 0.85rem;
        letter-spacing: 0.5px;
        min-height: 48px; /* touch target */
    }
    
    .form-group {
        margin-bottom: 18px;
    }
    
    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }
    
    .input-wrapper input {
        padding: 12px 12px 12px 40px;
        min-height: 48px;
        font-size: 16px;
    }
    
    .input-icon {
        left: 12px;
        width: 20px;
        height: 20px;
    }
    
    .input-hint,
    .input-hint-warning {
        font-size: 0.7rem;
    }
    
    /* SENHA e CONFIRMAR empilhados no mobile */
    .form-row.form-row-two {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row-two .form-group {
        margin-bottom: 18px;
    }
    
    .recaptcha-box {
        padding: 10px 12px;
        gap: 12px;
    }
    
    .recaptcha-checkbox {
        width: 26px;
        height: 26px;
        min-width: 26px;
    }
    
    .recaptcha-text {
        font-size: 0.85rem;
    }
    
    .btn-primary {
        min-height: 52px;
        padding: 16px;
        font-size: 1rem;
        margin-top: 8px;
    }
    
    .error-message {
        font-size: 0.8rem;
        padding: 10px;
    }
    
    .captcha-wrapper {
        flex-wrap: wrap;
    }
    
    .captcha-question {
        width: 100%;
    }
}

/* Mobile pequeno (iPhone SE, etc) */
@media (max-width: 380px) {
    .logo {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .card {
        padding: 16px 12px 12px;
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }
    
    .tab {
        padding: 12px 8px;
        font-size: 0.8rem;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .btn-primary {
        min-height: 48px;
        padding: 14px;
    }
}

/* Desktop grande - manter card proporcional */
@media (min-width: 769px) {
    .container {
        max-width: 480px;
    }
}
