/**
 * FunCards Authentication Pages
 * Modern, responsive styling for login/register/profile
 */

/* =========================
   CSS Variables
   ========================= */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
}

/* =========================
   Global Styles
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.auth-page {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* =========================
   Auth Container
   ========================= */
.auth-container {
    width: 100%;
    max-width: 450px;
    animation: fadeIn 0.5s ease-in-out;
}

/* Wider container for registration form */
body.register-page .auth-container.register-container {
    max-width: 650px !important;
}

.register-card {
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   Auth Card
   ========================= */
.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    position: relative;
}

/* =========================
   Language Switcher (Auth Pages)
   ========================= */
.language-switcher-auth {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.6);
    padding: 5px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.language-switcher-auth .lang-btn {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.language-switcher-auth .lang-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

.language-switcher-auth .lang-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* =========================
   Auth Header
   ========================= */
.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header h1 span {
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    color: inherit;
    display: inline-block;
    font-style: normal;
}

.auth-header h1 img.auth-logo-icon {
    vertical-align: middle;
    margin-right: 0.25em;
    object-fit: contain;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* =========================
   Alerts
   ========================= */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* CAPS Lock warning (shown below password field when Caps Lock is on) */
.caps-lock-warning {
    display: none;
    padding: 8px 12px;
    margin-top: 6px;
    font-size: 0.85rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 6px;
}
.caps-lock-warning.visible {
    display: block;
}

/* =========================
   Form Styles
   ========================= */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    margin-bottom: 20px;
}

.form-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    flex: 1;
    width: 100%;
}

/* Special styling for form-group containing CAPTCHA */
.form-group .captcha-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.biological-sex-explanation {
    margin: 14px 0 0 0;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border-left: 3px solid rgba(59, 130, 246, 0.5);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

/* Better spacing for registration form */
.register-card .form-row {
    gap: 20px;
    align-items: start;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6) !important;
    background-color: rgba(15, 23, 42, 0.6) !important; /* iOS Safari fallback */
    color: var(--text-primary) !important;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    flex-shrink: 0;
    -webkit-appearance: none !important; /* Remove iOS default styling */
    appearance: none !important;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select {
    cursor: pointer;
}

/* Honeypot field (hidden from users and assistive tech) */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Field hint text */
.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
    margin-bottom: 0;
}

/* Field errors */
.field-error {
    font-size: 0.85rem;
    color: var(--error);
    margin-top: -4px;
    min-height: 20px;
    display: block;
}

/* Inline validation error state */
input.input-error,
input:invalid.visited {
    border-color: var(--error);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

/* Login form error state: subtle shake */
.auth-form--error {
    animation: login-shake 0.4s ease-in-out;
}
@keyframes login-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Password field with visibility toggle */
.password-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    transition: all 0.3s ease;
}
.password-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.password-input-wrapper input {
    border: none !important;
    background: transparent !important;
    flex: 1;
    min-width: 0;
}
.password-input-wrapper input:focus {
    box-shadow: none !important;
}
.password-toggle {
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    border-radius: 0 8px 8px 0;
}
.password-toggle:hover {
    color: var(--text-primary);
}

/* Email not verified warning (login page) */
.login-email-not-verified {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #f59e0b;
}
.login-email-not-verified p {
    margin: 0 0 8px 0;
}
.login-resend-cta {
    margin-top: 10px !important;
}
.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Forgot password row */
.auth-forgot-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}
.auth-forgot-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* CAPTCHA group (only shown when required) */
.captcha-group {
    margin-top: 4px;
}
.captcha-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

/* =========================
   Consent Checkboxes
   ========================= */
.consent-checkbox-group {
    margin-bottom: 20px;
}

.consent-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.consent-checkbox-wrapper input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.consent-text {
    flex: 1;
    color: #cbd5e1;
    font-size: 0.95rem;
    line-height: 1.6;
}

.consent-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.consent-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

.consent-link:visited {
    color: #3b82f6;
}

/* Ensure form groups in rows align properly */
.form-row .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================
   Buttons
   ========================= */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
    background: #64748b;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

/* =========================
   Auth Footer
   ========================= */
.auth-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.auth-footer p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.auth-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* =========================
   CAPTCHA Widget (Cloudflare Turnstile)
   ========================= */
/* Wrapper for CAPTCHA widget - centers it */
.captcha-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 20px 0;
}

/* =========================
   Responsive Design
   ========================= */
@media (max-width: 768px) {
    .auth-container,
    .auth-container.register-container {
        max-width: 100%;
    }

    .auth-card {
        padding: 30px 20px;
    }

    .auth-header h1 {
        font-size: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .register-card .form-row {
        gap: 15px;
    }
}

@media (max-width: 640px) {
    body.register-page .auth-container.register-container {
        max-width: 100%;
    }
    
    .form-section {
        margin-bottom: 25px;
    }
    
    .form-section h3 {
        font-size: 1rem;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 10px;
    }

    .auth-card {
        padding: 25px 15px;
    }

    .captcha-wrapper {
        margin: 15px 0;
        padding: 10px 0;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    select {
        padding: 10px 14px;
    }
}
