/* =============================================================================
   AUTH LAYOUT — Estilos do layout base de autenticação
   Extraído de app/Auth/Views/layout.php
   ============================================================================= */

/* Fundo gradiente — alinhado ao tema público */
.auth-bg {
    background: linear-gradient(135deg, #0b0b1a 0%, #121240 50%, #0b0b1a 100%);
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

.auth-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(167, 139, 250, 0.12) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 80% 60%, rgba(52, 211, 153, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.auth-bg > * {
    position: relative;
    z-index: 1;
}

/* Card glassmorphism — estilo público */
.auth-card {
    background: rgba(30, 30, 56, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(100, 116, 139, 0.25);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 0 80px -20px rgba(167, 139, 250, 0.12);
}

/* Input estilizado */
.auth-input {
    background: rgba(11, 11, 26, 0.6);
    border: 1px solid rgba(100, 116, 139, 0.35);
    transition: all 0.2s ease;
    font-size: 16px;
    color: #f8fafc;
}

.auth-input:focus {
    background: rgba(11, 11, 26, 0.8);
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

/* Botões de ação no topo do card (home, tema) */
.auth-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(100, 116, 139, 0.3);
    color: #94a3b8;
    backdrop-filter: blur(8px);
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}
.auth-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.4);
}
.auth-icon-btn:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.6);
    outline-offset: 2px;
}

/* Botão primário — gradiente alinhado ao tema público */
.auth-btn-primary,
.auth-bg .ui-auth-btn-primary {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%) !important;
    border: none;
    transition: all 0.2s ease;
}

.auth-btn-primary:hover,
.auth-bg .ui-auth-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -10px rgba(167, 139, 250, 0.5) !important;
}

.auth-btn-primary:disabled,
.auth-bg .ui-auth-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-bg .ui-auth-btn-primary:focus {
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.3) !important;
}

/* Botão secundário */
.auth-btn-secondary {
    background: rgba(30, 30, 56, 0.6);
    border: 1px solid rgba(100, 116, 139, 0.35);
    transition: all 0.2s ease;
}

.auth-btn-secondary:hover {
    background: rgba(42, 42, 78, 0.7);
    border-color: rgba(167, 139, 250, 0.3);
}

/* Input focus — accent roxo no dark, rosa no light */
.auth-bg .ui-auth-input:focus {
    border-color: rgba(167, 139, 250, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15) !important;
}

/* Logo — gradiente roxo */
.auth-bg .ui-auth-logo {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%) !important;
}

/* Links de ação — cor roxa */
.auth-bg .ui-auth-footer-link-action,
.auth-bg .ui-auth-link,
.auth-bg .ui-auth-alert-link {
    color: #a78bfa !important;
}
.auth-bg .ui-auth-footer-link-action:hover,
.auth-bg .ui-auth-link:hover,
.auth-bg .ui-auth-alert-link:hover {
    color: #c4b5fd !important;
}

/* Method selector — accent roxo */
.auth-bg .ui-auth-method-btn.active {
    background-color: #8b5cf6 !important;
    color: white !important;
}
.auth-bg .ui-auth-method-btn:not(.active):hover {
    background-color: rgba(139, 92, 246, 0.1) !important;
}

/* Divisor */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: rgba(100, 116, 139, 0.35);
}

/* Toggle switch — accent roxo/rosa */
.auth-bg .ui-auth-remember-toggle input:checked + .ui-auth-toggle-track {
    background-color: #8b5cf6 !important;
}
html:not(.dark) .auth-bg .ui-auth-remember-toggle input:checked + .ui-auth-toggle-track {
    background-color: #ec4899 !important;
}

/* Credential toggle active */
.auth-bg .ui-auth-credential-btn.active {
    background-color: #8b5cf6 !important;
    border-color: #8b5cf6 !important;
    color: white !important;
}
html:not(.dark) .auth-bg .ui-auth-credential-btn.active {
    background-color: #ec4899 !important;
    border-color: #ec4899 !important;
    color: white !important;
}

/* Link para Home */
.auth-home-link {
    color: rgba(148, 163, 184, 0.8);
    text-decoration: none;
}

.auth-home-link:hover {
    color: #a78bfa;
}

html:not(.dark) .auth-home-link {
    color: #64748b;
}

html:not(.dark) .auth-home-link:hover {
    color: #ec4899;
}

/* Animações */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

/* Loader */
.auth-loader {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #a78bfa;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toggle de tema */
.theme-toggle {
    transition: all 0.3s ease;
}

/* Light mode overrides */
html:not(.dark) .auth-bg {
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 30%, #fff7ed 70%, #fefce8 100%);
}

html:not(.dark) .auth-bg::before {
    background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(236, 72, 153, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 80% 60%, rgba(249, 115, 22, 0.06) 0%, transparent 70%);
}

html:not(.dark) .auth-card {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(226, 232, 240, 0.6);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 25px 50px -12px rgba(0, 0, 0, 0.1),
        0 0 80px -20px rgba(236, 72, 153, 0.08);
}

html:not(.dark) .auth-btn-primary,
html:not(.dark) .auth-bg .ui-auth-btn-primary {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
}

html:not(.dark) .auth-btn-primary:hover,
html:not(.dark) .auth-bg .ui-auth-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%) !important;
    box-shadow: 0 10px 20px -10px rgba(236, 72, 153, 0.5) !important;
}

html:not(.dark) .auth-bg .ui-auth-btn-primary:focus {
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.2) !important;
}

html:not(.dark) .auth-input {
    background: rgba(248, 250, 252, 0.8);
    border-color: rgba(203, 213, 225, 0.8);
    color: #1e293b;
}

html:not(.dark) .auth-input::placeholder {
    color: #94a3b8;
}

html:not(.dark) .auth-input:focus,
html:not(.dark) .auth-bg .ui-auth-input:focus {
    background: white;
    border-color: rgba(236, 72, 153, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1) !important;
}

/* Light mode — Logo gradiente rosa */
html:not(.dark) .auth-bg .ui-auth-logo {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
}

/* Light mode — Links rosa */
html:not(.dark) .auth-bg .ui-auth-footer-link-action,
html:not(.dark) .auth-bg .ui-auth-link,
html:not(.dark) .auth-bg .ui-auth-alert-link {
    color: #db2777 !important;
}
html:not(.dark) .auth-bg .ui-auth-footer-link-action:hover,
html:not(.dark) .auth-bg .ui-auth-link:hover,
html:not(.dark) .auth-bg .ui-auth-alert-link:hover {
    color: #be185d !important;
}

/* Light mode — Method selector rosa */
html:not(.dark) .auth-bg .ui-auth-method-btn.active {
    background-color: #ec4899 !important;
    color: white !important;
}
html:not(.dark) .auth-bg .ui-auth-method-btn:not(.active):hover {
    background-color: rgba(236, 72, 153, 0.1) !important;
}

/* Light mode — Forgot password link */
html:not(.dark) .auth-bg a[href*="forgot-password"] {
    color: #db2777;
}
html:not(.dark) .auth-bg a[href*="forgot-password"]:hover {
    color: #be185d;
}

/* Light mode text colors */
html:not(.dark) .text-slate-300 { color: #475569; }
html:not(.dark) .text-slate-400 { color: #64748b; }
html:not(.dark) .ui-text-muted { color: #94a3b8; }
html:not(.dark) .text-white { color: #1e293b; }

/* Light mode heading colors */
html:not(.dark) h1.text-white,
html:not(.dark) .auth-card h1 {
    color: #0f172a !important;
}

/* Light mode alert text */
html:not(.dark) .text-red-300 { color: #dc2626; }
html:not(.dark) .text-green-300 { color: #16a34a; }
html:not(.dark) .text-amber-300 { color: #d97706; }
html:not(.dark) .text-green-400\/80 { color: #22c55e; }

/* Light mode button adjustments */
html:not(.dark) .login-method-btn:not(.bg-blue-600),
html:not(.dark) .recovery-method-btn:not(.bg-amber-600) {
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}
html:not(.dark) .login-method-btn:not(.bg-blue-600):hover,
html:not(.dark) .recovery-method-btn:not(.bg-amber-600):hover {
    background: rgba(226, 232, 240, 1);
    color: #1e293b;
}

/* Light mode credential type buttons */
html:not(.dark) .bg-slate-100 {
    background: #f1f5f9;
}
html:not(.dark) .bg-slate-700\/50,
html:not(.dark) .bg-slate-800 {
    background: #f1f5f9;
}

/* Light mode form elements */
html:not(.dark) .token-channel-option {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(203, 213, 225, 0.8);
    color: #475569;
}
html:not(.dark) .token-channel-option:hover {
    border-color: rgba(59, 130, 246, 0.5);
}
html:not(.dark) .token-channel-option:has(:checked) {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Light mode OTP info box */
html:not(.dark) .bg-blue-50 {
    background: rgba(239, 246, 255, 0.9);
}
html:not(.dark) .border-blue-200 {
    border-color: rgba(191, 219, 254, 0.8);
}

/* Light mode select dropdown */
html:not(.dark) select.auth-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Light mode social login grid */
html:not(.dark) #form-social .auth-input {
    background: rgba(248, 250, 252, 0.8);
    border-color: rgba(203, 213, 225, 0.8);
}
html:not(.dark) #form-social .auth-input:hover {
    background: rgba(241, 245, 249, 1);
}

/* Light mode alternative methods */
html:not(.dark) .border-slate-700 {
    border-color: #e2e8f0;
}
html:not(.dark) .border-slate-600 {
    border-color: #cbd5e1;
}
html:not(.dark) .border-slate-600\/50 {
    border-color: rgba(203, 213, 225, 0.5);
}

/* Light mode divider */
html:not(.dark) .auth-divider::before,
html:not(.dark) .auth-divider::after {
    background-color: rgba(203, 213, 225, 0.8);
}

/* Light mode password strength bar */
html:not(.dark) #password-strength {
    background: #e2e8f0;
}

/* Light mode checkbox */
html:not(.dark) .bg-slate-600 {
    background: #cbd5e1;
}

/* Light mode icon colors */
html:not(.dark) .text-emerald-400 {
    color: #059669;
}
html:not(.dark) .text-blue-400 {
    color: #2563eb;
}
html:not(.dark) .text-amber-400 {
    color: #d97706;
}
html:not(.dark) .text-green-400 {
    color: #16a34a;
}
html:not(.dark) .text-purple-400 {
    color: #9333ea;
}
html:not(.dark) .text-cyan-400 {
    color: #06b6d4;
}
html:not(.dark) .text-indigo-400 {
    color: #6366f1;
}
html:not(.dark) .text-red-400 {
    color: #dc2626;
}

/* Light mode background colors */
html:not(.dark) .bg-blue-500\/10,
html:not(.dark) .bg-amber-500\/10,
html:not(.dark) .bg-green-500\/10,
html:not(.dark) .bg-purple-500\/10,
html:not(.dark) .bg-cyan-500\/10,
html:not(.dark) .bg-indigo-500\/10 {
    background: rgba(241, 245, 249, 0.9);
}

/* Social login method tab button - white text when selected */
.login-method-btn.bg-blue-600 {
    color: white !important;
}
.login-method-btn.bg-blue-600 svg {
    color: white !important;
}

/* Social login buttons - Dark mode: icons white */
.dark #form-social .grid a.auth-input svg,
.dark #form-social .grid a.auth-input [class^="social-icon-"] svg {
    color: white !important;
}

/* Phone field responsive layout */
#phone-field > .flex.gap-2 {
    flex-wrap: nowrap;
}

#phone-field select.auth-input {
    flex-shrink: 0;
    width: auto;
    min-width: 95px;
    max-width: 100px;
}

#phone-field input[type="tel"] {
    min-width: 0;
    flex: 1;
}

/* OTP buttons - prevent overflow */
.bg-blue-50 .flex.gap-2 button,
.bg-blue-900\/10 .flex.gap-2 button {
    white-space: nowrap;
    font-size: 0.7rem;
    padding: 0.375rem 0.5rem;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .auth-card {
        margin: 0;
        border-radius: 1rem;
        max-width: 100%;
        overflow-x: hidden;
        padding: 1.25rem !important;
    }

    .auth-card > div:first-child h1 {
        font-size: 1.5rem;
    }

    /* Botões de método de login - ajustar para wrap */
    .login-method-btn,
    .recovery-method-btn {
        flex: 1 1 auto;
        min-width: calc(50% - 0.25rem);
    }

    /* Inputs OTP menores em mobile (fallback for non-ui-auth classes) */
    .otp-input,
    .code-digit {
        width: 2.25rem !important;
        height: 2.75rem !important;
        font-size: 1.125rem !important;
    }

    /* Grid de social login (fallback for old class) */
    .social-login-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Phone field - ajustes para mobile */
    #phone-field select.auth-input {
        min-width: 85px;
        max-width: 90px;
        padding-left: 0.5rem;
        padding-right: 0.25rem;
        font-size: 0.813rem;
    }

    /* OTP buttons em mobile - stack vertical */
    .bg-blue-50 .flex.gap-2,
    .bg-blue-900\/10 .flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem;
    }

    .bg-blue-50 .flex.gap-2 button,
    .bg-blue-900\/10 .flex.gap-2 button {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* Auth title - smaller on mobile */
    .ui-auth-title {
        font-size: 1.375rem;
    }
}

@media (max-width: 360px) {
    .auth-card {
        padding: 1rem !important;
    }

    .otp-input,
    .code-digit {
        width: 1.875rem !important;
        height: 2.5rem !important;
        font-size: 1rem !important;
    }

    .social-login-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Phone field em telas muito pequenas */
    #phone-field select.auth-input {
        min-width: 75px;
        max-width: 80px;
        font-size: 0.75rem;
    }

    /* Auth title - even smaller */
    .ui-auth-title {
        font-size: 1.25rem;
    }
}

/* Safe area para dispositivos com notch */
@supports (padding: max(0px)) {
    .auth-bg > div {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Transição suave para tema */
html {
    transition: background-color 0.3s ease;
}

.auth-bg,
.auth-card,
.auth-input {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* =============================================================================
   INTL-TEL-INPUT — Estilização para tema escuro
   ============================================================================= */

/* Estilização do intl-tel-input para tema escuro */
.iti { width: 100%; }
.iti__tel-input { width: 100%; }
.iti__country-container {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 0.5rem 0 0 0.5rem;
}
.iti__selected-country {
    background: transparent !important;
    border-radius: 0.5rem 0 0 0.5rem;
}
.iti__selected-country:hover,
.iti__selected-country:focus {
    background: rgba(71, 85, 105, 0.3) !important;
}
.iti__dropdown-content {
    background: #1e293b;
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}
.iti__search-input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    color: white;
    border-radius: 0.375rem;
}
.iti__country {
    padding: 8px 12px;
    color: #e2e8f0;
}
.iti__country:hover {
    background: rgba(59, 130, 246, 0.2);
}
.iti__country--highlight {
    background: rgba(59, 130, 246, 0.3);
}
.iti__dial-code {
    color: #94a3b8;
}
.iti__arrow {
    border-top-color: #94a3b8;
}
.iti__arrow--up {
    border-bottom-color: #94a3b8;
}
.iti__selected-dial-code {
    color: #e2e8f0;
}
/* Light mode overrides */
html:not(.dark) .iti__country-container {
    background: rgba(248, 250, 252, 0.9);
}
html:not(.dark) .iti__dropdown-content {
    background: white;
    border-color: rgba(203, 213, 225, 0.8);
}
html:not(.dark) .iti__search-input {
    background: #f8fafc;
    border-color: rgba(203, 213, 225, 0.8);
    color: #1e293b;
}
html:not(.dark) .iti__country {
    color: #334155;
}
html:not(.dark) .iti__dial-code {
    color: #64748b;
}
html:not(.dark) .iti__arrow {
    border-top-color: #64748b;
}
html:not(.dark) .iti__selected-dial-code {
    color: #334155;
}

/* =============================================================================
   COOKIE CONSENT — Animação fade-in do modal
   ============================================================================= */

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.animate-fade-in { animation: fade-in 0.3s ease-out; }
