/* ==========================================
   LOGIN — pantalla de acceso
   ========================================== */

/* Lock scroll on login page via html/body — avoids position:fixed
   which fights Safari autofill and causes viewport displacement. */
.login-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.login-screen {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Premium gradient background - dark gray */
    background: radial-gradient(ellipse at top, #252525 0%, #181818 50%, #111111 100%);
}

/* Panel principal */

.login-panel {
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 26px;
    overflow-y: auto;

    /* Glass card effect with blur */
    backdrop-filter: blur(12px);
    background: rgba(14, 14, 14, 0.85);
    padding: 36px 34px 28px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-screen label {
    display: block;
    font-size: 0.80rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 6px;       /* separación entre label e input */
    letter-spacing: 0.3px;
}

/* Branding login */

.logo-block {
    text-align: center;
    margin-top: -110px;
    margin-bottom: -140px;
}

.logo-img {
    width: 350px;
    height: 350px;
    object-fit: contain;
    margin-bottom: 18px;
}

.brand-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.brand-subtitle {
    text-align: center;
    width: 100%;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Roboto', sans-serif;
}

/* Form login */

.login-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.login-form .form-footer {
    margin-top: 8px;
    display: flex;
    justify-content: center;
}

.login-form .btn-primary {
    min-width: 120px;
}

/* Footer login */

.footer-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.legal-text {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'Roboto', sans-serif;
}

.support-link {
    font-size: 12px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    opacity: 0.85;
    transition: 0.15s ease;
    padding: 0;
}

.support-link:hover {
    opacity: 1;
}

/* Pricing link */

.login-pricing-link {
    text-align: center;
}

.pricing-link-btn {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.15s ease;
    font-family: 'Roboto', sans-serif;
}

.pricing-link-btn:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Estado de autenticación (mensajes) */

.auth-message {
    margin-top: 8px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.auth-message--error {
    color: #f97373;
}

/* Botón con loading */

.btn-primary--loading {
    cursor: wait;
    opacity: 0.9;
}

.btn-primary__inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Logo loading indicator: OCULTO por defecto */
.btn-primary__spinner {
    display: none;
    width: 30px;
    height: 30px;
    object-fit: contain;
    animation: fadeOnly 1.5s ease-in-out infinite;
    flex-shrink: 0;  /* No permitir que se comprima */
}

/* Cuando está en loading: ocultar texto y mostrar solo logo */
.btn-primary--loading .btn-primary__label {
    display: none;
}

.btn-primary--loading .btn-primary__spinner {
    display: inline-block;
}

/* Fade animation for login button logo */
@keyframes fadeOnly {
    0% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.3;
    }
}

/* ==================================================
   BOTÓN PRINCIPAL SOLO PARA LOGIN
   (sobreescribe el .btn-primary global dentro de .login-screen)
   ================================================== */

.login-screen .btn-primary {
    /* Gana en especificidad sobre .btn-primary global */
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: auto;
    height: 44px;  /* Altura fija para que no crezca con el spinner */
    margin: 16px auto 0 auto;   /* ← AQUÍ SE CONTROLA TODO EL ESPACIADO */
    border: none;
    cursor: pointer;

    border-radius: 14px; /* más premium */
    padding: 0;

    background: var(--accent);
    color: #000000;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);

    transition:
        transform 0.12s ease-out,
        box-shadow 0.12s ease-out,
        background 0.2s ease-out;
}

.login-screen .btn-primary__inner {
    width: 100%;
    height: 100%;  /* Usa toda la altura del botón padre */
    padding: 0 16px;  /* Solo padding horizontal */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    font-size: 0.95rem;
    font-weight: 500;
}

/* Hover / active solo en login */
.login-screen .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.38);
}

.login-screen .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 6px 10px rgba(0,0,0,0.28);
}

/* Inputs base */

.input {
    width: 100%;
    padding: 10px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.input:focus {
    border-color: var(--accent);
    background: var(--bg-input-hover);
}

/* Override browser autofill styles */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Firefox autofill */
.input:-moz-autofill,
.input:-moz-autofill-preview {
    filter: none !important;
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

/* ==========================================
   MOBILE & PWA RESPONSIVE
   ========================================== */

/* Safe area insets for PWA standalone mode */
@media (display-mode: standalone) {
    .login-page {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .login-screen {
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
    }

    .login-panel {
        max-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .login-screen {
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .login-panel {
        padding: 24px 20px 20px;
        gap: 14px;
        max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        border-radius: var(--radius-lg);
        border: 1px solid rgba(255, 255, 255, 0.06);
        background: rgba(14, 14, 14, 0.85);
        backdrop-filter: blur(12px);
        /* Allow content to shrink to fit */
        justify-content: center;
    }

    .logo-block {
        margin-top: -50px;
        margin-bottom: -70px;
        flex-shrink: 1;
    }

    .logo-img {
        width: 200px;
        height: 200px;
        max-width: 45vw;
        max-height: 45vw;
    }

    /* Prevent iOS zoom on input focus */
    .input {
        font-size: 16px;
        padding: 14px 16px;
        border-radius: var(--radius-lg);
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        -webkit-tap-highlight-color: transparent;
    }

    .input:focus {
        background: var(--bg-active);
        border-color: rgba(61, 202, 139, 0.4);
    }

    .login-form {
        gap: 18px;
    }

    .login-screen .btn-primary {
        height: 50px;
        width: 100%;
        border-radius: var(--radius-lg);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .login-screen .btn-primary:active {
        transform: scale(0.98);
    }

    .brand-title {
        font-size: 18px;
    }

    .brand-subtitle {
        font-size: 12px;
    }

    .footer-block {
        margin-top: 8px;
    }

    .legal-text {
        font-size: 10px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .login-panel {
        padding: 16px 14px 14px;
        gap: 12px;
    }

    .logo-block {
        margin-top: -40px;
        margin-bottom: -60px;
    }

    .logo-img {
        width: 160px;
        height: 160px;
        max-width: 40vw;
        max-height: 40vw;
    }

    .brand-title {
        font-size: 16px;
    }

    .login-form {
        gap: 12px;
    }

    .footer-block {
        margin-top: 4px;
    }
}

/* Very small screens (height-based) */
@media (max-height: 600px) {
    .login-panel {
        gap: 10px;
    }

    .logo-block {
        margin-top: -40px;
        margin-bottom: -60px;
    }

    .logo-img {
        width: 140px;
        height: 140px;
    }

    .login-form {
        gap: 12px;
    }

    .footer-block {
        margin-top: 4px;
    }

    .brand-subtitle {
        margin-top: 4px;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .input {
        /* Prevent zoom on iOS when focusing input */
        font-size: 16px;
    }

    /* -webkit-fill-available accounts for Safari toolbar/address bar */
    .login-page {
        height: -webkit-fill-available;
    }
}

/* Keyboard open state */
@media (max-width: 480px) {
    .login-page.keyboard-open {
        /* Let Safari manage viewport naturally when keyboard/autofill is open */
        overflow: visible;
        height: auto;
    }

    .login-page.keyboard-open .login-screen {
        align-items: flex-start;
        padding-top: calc(24px + env(safe-area-inset-top));
        height: auto;
        min-height: 100dvh;
    }

    .login-page.keyboard-open .login-panel {
        max-height: none;
    }

    /* Hide logo when keyboard is open to save space */
    .login-page.keyboard-open .logo-block {
        display: none;
    }

    /* Hide footer when keyboard is open */
    .login-page.keyboard-open .footer-block {
        display: none;
    }

    .login-page.keyboard-open .brand-subtitle {
        display: none;
    }
}

/* ==========================================
   LOGIN TRANSITION OVERLAY
   Shown after successful login, before redirect
   ========================================== */

.login-transition-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-top);
    gap: 16px;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.login-transition-overlay.visible {
    display: flex;
    opacity: 1;
}

.login-transition-overlay .transition-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    animation: pulse 1.5s ease-in-out infinite;
}

.login-transition-overlay .transition-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-family: system-ui, -apple-system, sans-serif;
    letter-spacing: 0.05em;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}