/* Authentication Views Mobile Responsive Improvements */

/* Reserve space for footer (used by min-height calc on auth pages) */
:root {
    --footer-offset: 72px;
    /* Dynamic height of GDPR banner, updated by gdpr.js */
    --gdpr-banner-height: 0px;
}
@media (min-width: 576px) {
    :root {
        --footer-offset: 80px;
    }
}
@media (min-width: 768px) {
    :root {
        --footer-offset: 96px;
    }
}

/* General Auth Container Improvements */
.auth-container {
    padding: 1rem 0.5rem;
    /* Ensure footer is not overlapped by auth content */
    margin-bottom: 2.5rem;
    /* Make sure content area fills the viewport minus footer */
    min-height: calc(100vh - var(--footer-offset)); /* fallback */
    min-height: calc(100dvh - var(--footer-offset)); /* modern mobile-friendly */
    /* Add bottom padding when GDPR banner is visible (set by gdpr.js) */
    padding-bottom: calc(var(--gdpr-banner-height, 0px) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 576px) {
    .auth-container {
        padding: 1.5rem 1rem;
    }
}

@media (min-width: 768px) {
    .auth-container {
        padding: 3rem 1rem;
        margin-bottom: 3rem; /* extra breathing room on md+ */
        /* Slightly larger footer on md+ screens */
        --footer-offset: 112px;
    }
}

/* Register page: ensure no visual overlap with footer/cookie UI */
.auth-container.auth-register {
    /* reduce extra bottom whitespace now that overflow is enabled */
    margin-bottom: 3.5rem; /* was 6.5rem */
    min-height: calc(100vh - var(--footer-offset) + 48px);
    min-height: calc(100dvh - var(--footer-offset) + 48px);
    /* Extra bottom padding to fully avoid GDPR banner overlap */
    padding-bottom: calc(var(--gdpr-banner-height, 0px) + 16px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) {
    .auth-container.auth-register {
        margin-bottom: 4.5rem; /* was 7.5rem */
        min-height: calc(100vh - var(--footer-offset) + 64px);
        min-height: calc(100dvh - var(--footer-offset) + 64px);
    }
}
/* Add a little bottom cushion inside the card on register */
.auth-register .auth-card-body {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 576px) {
    .auth-register .auth-card-body {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    }
}

/* Register page: cap card height to viewport and allow internal scrolling to avoid footer/GDPR overlap */
/* This keeps the form fully usable on small screens without hiding under fixed elements */
.auth-container.auth-register .auth-card {
    max-height: calc(100dvh - var(--footer-offset) - var(--gdpr-banner-height, 0px) - 4px); /* tighter buffer (was 24px) */
    display: flex;
    flex-direction: column;
}
.auth-container.auth-register .auth-card-body {
    flex: 1 1 auto; /* let body fill the available height inside the card */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
@media (min-width: 768px) {
    .auth-container.auth-register .auth-card {
        max-height: none;
    }
    .auth-container.auth-register .auth-card-body {
        overflow: visible;
    }
}

/* Global mobile overflow handling for all auth forms */
@media (max-width: 767.98px) {
    .auth-container .auth-card {
        max-height: calc(100dvh - var(--footer-offset) - var(--gdpr-banner-height, 0px));
        display: flex;
        flex-direction: column;
    }
    .auth-container .auth-card-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* Auth Card Responsive Design */
.auth-card {
    margin: 0.5rem;
    border-radius: 1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    backdrop-filter: saturate(140%) blur(8px);
    border: 1px solid rgba(2, 6, 23, 0.06);
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.06), 0 4px 12px rgba(2, 6, 23, 0.05);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}
@media (hover: hover) {
    .auth-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 18px 40px rgba(2, 6, 23, 0.08), 0 6px 18px rgba(2, 6, 23, 0.06);
    }
}
[data-bs-theme="dark"] .auth-card {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.85), rgba(17, 24, 39, 0.75));
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* Brand theming for auth views (uses Bootstrap --bs-primary) */
:root {
    --auth-brand-primary: var(--bs-primary);
    --auth-brand-primary-rgb: var(--bs-primary-rgb, 13,110,253);
    --auth-shadow-elevated: 0 12px 30px rgba(2, 6, 23, 0.06), 0 4px 12px rgba(2, 6, 23, 0.05);
    --auth-shadow-elevated-hover: 0 18px 40px rgba(2, 6, 23, 0.08), 0 6px 18px rgba(2, 6, 23, 0.06);
    --auth-shadow-brand: 0 8px 24px rgba(var(--auth-brand-primary-rgb), 0.08);
    --auth-shadow-brand-hover: 0 12px 32px rgba(var(--auth-brand-primary-rgb), 0.12);
}

/* Card: add subtle brand tint to background, border and shadows */
/* Use color-mix when available for nuanced tints */
@supports (background: color-mix(in srgb, #fff 95%, #000 5%)) {
    .auth-card {
        background: linear-gradient(
            180deg,
            color-mix(in srgb, var(--bs-body-bg) 96%, var(--auth-brand-primary) 4%),
            color-mix(in srgb, var(--bs-body-bg) 98%, var(--auth-brand-primary) 2%)
        );
    }
    [data-bs-theme="dark"] .auth-card {
        background: linear-gradient(
            180deg,
            color-mix(in srgb, #0b1020 88%, var(--auth-brand-primary) 12%),
            color-mix(in srgb, #0b1020 92%, var(--auth-brand-primary) 8%)
        );
    }
}

.auth-card {
    border-color: rgba(var(--auth-brand-primary-rgb), 0.12);
    box-shadow: var(--auth-shadow-elevated), var(--auth-shadow-brand);
}
@media (hover: hover) {
    .auth-card:hover {
        box-shadow: var(--auth-shadow-elevated-hover), var(--auth-shadow-brand-hover);
    }
}
[data-bs-theme="dark"] .auth-card {
    border-color: rgba(var(--auth-brand-primary-rgb), 0.22);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(var(--auth-brand-primary-rgb), 0.10);
}

/* Inputs: neutral focus styling (no blue borders) */
.auth-form .form-control:focus,
.auth-input-group .form-control:focus {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Social box: align border/shadow with brand */
.auth-social-box {
    border-color: rgba(var(--auth-brand-primary-rgb), 0.12);
    box-shadow: 0 6px 16px rgba(var(--auth-brand-primary-rgb), 0.06), 0 1px 4px rgba(2, 6, 23, 0.06);
}
[data-bs-theme="dark"] .auth-social-box {
    border-color: rgba(var(--auth-brand-primary-rgb), 0.18);
    box-shadow: 0 8px 18px rgba(var(--auth-brand-primary-rgb), 0.08), 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Title polish */
.auth-title {
    letter-spacing: -0.01em;
    font-weight: 700;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .auth-card,
    .auth-submit-btn { transition: none; }
}

/* Better spacing for mobile */
@media (max-width: 575.98px) {
    .auth-form .row.g-2 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
}

/* Additional mobile viewport fixes */
@media (max-width: 575.98px) {
    /* Ensure no horizontal scrolling on mobile */
    .container-fluid,
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        overflow-x: hidden;
    }

    /* Better touch targets for mobile */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    /* Input field improvements for mobile */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        line-height: 1.5;
        min-height: 44px;
    }

    /* Social buttons stack properly on very small screens */
    .auth-social-btn {
        margin-bottom: 0.5rem;
    }

    /* Reduce spacing for mobile to fit more content */
    .auth-card-body {
        padding: 1.25rem 1rem !important;
    }

    /* Make alerts more compact on mobile */
    .auth-alert {
        font-size: 0.85rem;
        padding: 0.75rem;
    }

    /* Better mobile typography */
    .auth-title {
        font-size: 1.4rem;
        line-height: 1.2;
    }

    /* Compact form spacing */
    .form-label {
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
        font-weight: 600;
    }

    /* Better mobile input groups */
    .auth-input-group .input-group-text {
        min-width: 44px;
        padding: 0.75rem 0.5rem;
    }

    /* Mobile-optimized button sizing */
    .auth-submit-btn {
        font-size: 1.1rem;
        padding: 1rem;
        font-weight: 600;
    }
}

/* Landscape mobile optimization */
@media (max-width: 767.98px) and (orientation: landscape) {
    .auth-container {
        padding: 1rem 0.5rem;
    }

    .auth-card-body {
        padding: 1.5rem 1rem !important;
    }

    .auth-title {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    .auth-alert {
        margin-bottom: 1rem;
    }
}

/* Fix for very small screens (iPhone SE, etc.) */
@media (max-width: 374px) {
    .auth-card {
        margin: 0.25rem;
    }

    .auth-card-body {
        padding: 1rem 0.75rem !important;
    }

    .auth-title {
        font-size: 1.3rem;
    }

    .auth-social-btn {
        padding: 0.625rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* Authentication JavaScript Enhancements */

/* Password toggle button positioned inside input */
.password-toggle,
.toggle-password,
.toggle-password-confirm {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    border: none !important;
    background: transparent !important;
    color: #6c757d;
    transition: all 0.2s ease;
    padding: 6px 8px;
    border-radius: 6px;
    width: auto;
    height: auto;
    min-width: unset;
    font-size: 16px;
}

/* Simplified styling since no conflict with error icons */
.auth-input-group .is-invalid ~ .toggle-password,
.auth-input-group .is-invalid ~ .toggle-password-confirm {
    right: 8px;
    z-index: 10;
}

.password-toggle:hover,
.toggle-password:hover,
.toggle-password-confirm:hover {
    color: #495057;
    background: rgba(108, 117, 125, 0.15) !important;
}

.password-toggle:focus,
.toggle-password:focus,
.toggle-password-confirm:focus {
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.1) !important;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25) !important;
    outline: none !important;
}

.password-toggle:active,
.toggle-password:active,
.toggle-password-confirm:active {
    color: #0a58ca;
    background: rgba(13, 110, 253, 0.2) !important;
}

/* Input focus animations */
.auth-form .input-group.focused {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

.auth-form .input-group.focused .input-group-text {
    border-color: #0d6efd;
    color: #0d6efd;
}

/* Form validation styles */
.auth-form .is-valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.1);
}

.auth-form .is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.1);
    /* Remove background error icons completely */
    background-image: none !important;
    background-position: unset !important;
}

/* Reset padding for password fields - no need for extra space without background icons */
.auth-input-group .form-control[type="password"].is-invalid {
    padding-right: 45px; /* Only space for toggle button */
}

.auth-input-group:has(.toggle-password) .form-control.is-invalid,
.auth-input-group:has(.toggle-password-confirm) .form-control.is-invalid {
    padding-right: 45px; /* Only space for toggle button */
}

/* For non-password fields, use normal padding */
.auth-form .form-control:not([type="password"]).is-invalid {
    padding-right: calc(0.75em + 0.375rem); /* Bootstrap default */
}

/* Custom feedback styling with error icons */
.auth-form .invalid-feedback {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex !important;
    align-items: center;
    gap: 0.375rem;
}

/* Add error icon before feedback text */
.auth-form .invalid-feedback::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' fill='%23dc3545'%3e%3cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/%3e%3cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: contain;
    flex-shrink: 0;
}

/* Form error alert */
.auth-form-error {
    border-radius: 8px;
    margin-bottom: 1rem;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading button states */
.auth-form button[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Notification styles */
.auth-notification {
    animation: slideInRight 0.3s ease;
    border-radius: 8px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced input groups with consistent sizing */
.auth-input-group {
    position: relative;
    width: 100%;
}

.auth-input-group .input-group-text {
    transition: all 0.2s ease;
    min-width: 45px;
    justify-content: center;
    background-color: #f8f9fa;
    border-right: none;
}

.auth-input-group .form-control {
    border-left: none;
    padding-right: 12px; /* Default padding */
}

/* Special handling for password fields with toggle buttons */
.auth-input-group:has(.toggle-password) .form-control,
.auth-input-group:has(.toggle-password-confirm) .form-control {
    padding-right: 45px;
}

/* Fallback for browsers without :has() support */
.auth-input-group .form-control[type="password"] {
    padding-right: 45px;
}

/* For non-password inputs, ensure consistent padding */
.auth-input-group .form-control:not([type="password"]) {
    padding-right: 12px;
}

.auth-input-group:focus-within .input-group-text {
    border-color: #0d6efd;
    color: #0d6efd;
    background-color: #f8f9ff;
}

/* Mobile enhancements */
@media (max-width: 576px) {
    .password-toggle,
    .toggle-password,
    .toggle-password-confirm {
        padding: 6px 8px;
        font-size: 0.9rem;
        right: 6px;
    }

    /* Simplified mobile styling - no need for complex error icon positioning */
    .auth-input-group .form-control[type="password"].is-invalid {
        padding-right: 42px; /* Only space for toggle button on mobile */
    }

    .auth-input-group:has(.toggle-password) .form-control.is-invalid,
    .auth-input-group:has(.toggle-password-confirm) .form-control.is-invalid {
        padding-right: 42px; /* Only space for toggle button on mobile */
    }

    .auth-notification {
        right: 10px;
        left: 10px;
        min-width: auto;
    }

    /* Better mobile feedback styling */
    .auth-form .invalid-feedback {
        font-size: 0.8rem;
        gap: 0.25rem;
    }

    .auth-form .invalid-feedback::before {
        width: 14px;
        height: 14px;
    }
}

/* ===== NUCLEAR BOOTSTRAP OVERRIDES ===== */
/* These rules have maximum specificity to override any Bootstrap hover effects */

/* Complete removal of input hover effects */
.auth-form .form-control:hover,
.auth-form .form-control:hover:not(:focus),
.auth-input-group .form-control:hover,
.auth-input-group .form-control:hover:not(:focus),
.auth-form input:hover,
.auth-form input:hover:not(:focus),
.auth-input-group input:hover,
.auth-input-group input:hover:not(:focus),
.form-control:hover,
.form-control:hover:not(:focus),
input.form-control:hover,
input.form-control:hover:not(:focus) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    background-color: #fff !important;
    color: #212529 !important;
    outline: none !important;
}

/* Dark theme overrides */
[data-bs-theme="dark"] .auth-form .form-control:hover,
[data-bs-theme="dark"] .auth-form .form-control:hover:not(:focus),
[data-bs-theme="dark"] .auth-input-group .form-control:hover,
[data-bs-theme="dark"] .auth-input-group .form-control:hover:not(:focus),
[data-bs-theme="dark"] .form-control:hover,
[data-bs-theme="dark"] .form-control:hover:not(:focus) {
    border-color: #495057 !important;
    box-shadow: none !important;
    background-color: #212529 !important;
    color: #fff !important;
}

/* Input group text hover overrides */
.auth-input-group:hover .input-group-text,
.auth-input-group .input-group-text:hover,
.input-group:hover .input-group-text,
.input-group .input-group-text:hover {
    border-color: #dee2e6 !important;
    background-color: #f8f9fa !important;
    color: #6c757d !important;
}

[data-bs-theme="dark"] .auth-input-group:hover .input-group-text,
[data-bs-theme="dark"] .auth-input-group .input-group-text:hover {
    border-color: #495057 !important;
    background-color: #343a40 !important;
    color: #adb5bd !important;
}

/* Override any potential focus-within effects */
.auth-input-group:hover:not(:focus-within),
.input-group:hover:not(:focus-within) {
    box-shadow: none !important;
}

/* Preserve only subtle focus states (no blue border) */
.auth-form .form-control:focus,
.auth-input-group .form-control:focus {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    outline: none !important;
    background-color: #fff !important;
}

.auth-input-group:focus-within .input-group-text {
    border-color: #dee2e6 !important;
    color: #6c757d !important;
    background-color: #f8f9fa !important;
}

[data-bs-theme="dark"] .auth-form .form-control:focus,
[data-bs-theme="dark"] .auth-input-group .form-control:focus {
    border-color: #495057 !important;
    background-color: #212529 !important;
}

[data-bs-theme="dark"] .auth-input-group:focus-within .input-group-text {
    border-color: #495057 !important;
    color: #adb5bd !important;
    background-color: #343a40 !important;
}

/* Additional nuclear overrides for any remaining Bootstrap classes */
.form-floating:hover .form-control,
.form-floating .form-control:hover,
.input-group:hover .form-control,
.input-group .form-control:hover,
div:hover .form-control:not(:focus),
.container:hover .form-control:not(:focus),
.row:hover .form-control:not(:focus),
.col:hover .form-control:not(:focus),
.auth-container:hover .form-control:not(:focus) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    background-color: #fff !important;
}

/* Bootstrap 5.x specific overrides */
.form-control:not(:disabled):not([readonly]):hover,
.form-control:not(:disabled):not([readonly]):hover:not(:focus) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    background-color: #fff !important;
}

/* CSS specificity nuclear option - using attribute selectors */
input[class*="form-control"]:hover:not(:focus),
input[class*="form-control"]:hover:not(:focus):not(:active) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    background-color: #fff !important;
}

/* Final nuclear option - target by element and class combination */
input.form-control:hover:not(:focus):not(:active):not(.is-invalid):not(.is-valid) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    background-color: #fff !important;
    color: #212529 !important;
}

/* ===== NUCLEAR FOCUS BORDER REMOVAL ===== */
/* Complete elimination of any blue focus effects */

.auth-form .form-control:focus,
.auth-form .form-control:focus:not(.is-invalid):not(.is-valid),
.auth-input-group .form-control:focus,
.auth-input-group .form-control:focus:not(.is-invalid):not(.is-valid),
.form-control:focus,
.form-control:focus:not(.is-invalid):not(.is-valid),
input:focus,
input:focus:not(.is-invalid):not(.is-valid),
input.form-control:focus,
input.form-control:focus:not(.is-invalid):not(.is-valid),
input[class*="form-control"]:focus,
input[class*="form-control"]:focus:not(.is-invalid):not(.is-valid) {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    outline: none !important;
    background-color: #fff !important;
    color: #212529 !important;
}

/* Dark theme focus overrides */
[data-bs-theme="dark"] .auth-form .form-control:focus,
[data-bs-theme="dark"] .auth-input-group .form-control:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] input:focus,
[data-bs-theme="dark"] input.form-control:focus {
    border-color: #495057 !important;
    box-shadow: none !important;
    outline: none !important;
    background-color: #212529 !important;
    color: #fff !important;
}

/* Input group focus-within overrides */
.auth-input-group:focus-within,
.input-group:focus-within {
    box-shadow: none !important;
}

.auth-input-group:focus-within .input-group-text,
.input-group:focus-within .input-group-text {
    border-color: #dee2e6 !important;
    color: #6c757d !important;
    background-color: #f8f9fa !important;
}

[data-bs-theme="dark"] .auth-input-group:focus-within .input-group-text,
[data-bs-theme="dark"] .input-group:focus-within .input-group-text {
    border-color: #495057 !important;
    color: #adb5bd !important;
    background-color: #343a40 !important;
}
