/**
 * BroPro Universal Authentication Modal Styles
 * Matches exact production design from reference image:
 * - Rounded pill tabs (Login / Sign Up)
 * - Waving hand icon with subtle animation
 * - 1-Click Google OAuth button
 * - Clean dark inputs with glowing focus borders
 * - Vibrant gradient CTA action buttons
 * - CSS Variables for theme tinting across verticals:
 *   - /learn/: Indigo / Violet
 *   - /: Emerald / Golden Amber
 *   - /news/: Crimson / Slate
 *   - /compassion-zone/: Soft Emerald / Rose
 */

:root {
    --auth-theme-bg: #0d121d;
    --auth-theme-card-bg: rgba(13, 18, 29, 0.95);
    --auth-theme-border: rgba(255, 255, 255, 0.1);
    --auth-theme-accent: #8b5cf6;
    --auth-theme-accent-hover: #a78bfa;
    --auth-theme-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --auth-theme-shadow: rgba(99, 102, 241, 0.38);
    --auth-theme-tab-active: rgba(255, 255, 255, 0.14);
}

/* Vertical-Specific Overrides */
/* 1. Ecosystem Homepage */
body[data-auth-theme="ecosystem"],
.auth-theme-ecosystem {
    --auth-theme-bg: #0a1114;
    --auth-theme-card-bg: rgba(10, 17, 20, 0.96);
    --auth-theme-border: rgba(16, 185, 129, 0.25);
    --auth-theme-accent: #10b981;
    --auth-theme-accent-hover: #34d399;
    --auth-theme-gradient: linear-gradient(135deg, #059669 0%, #d97706 100%);
    --auth-theme-shadow: rgba(16, 185, 129, 0.35);
    --auth-theme-tab-active: rgba(16, 185, 129, 0.2);
}

/* 2. BroPro Learning Hub (matches reference image purple/indigo) */
body[data-auth-theme="learn"],
.auth-theme-learn {
    --auth-theme-bg: #0b0f19;
    --auth-theme-card-bg: rgba(11, 15, 25, 0.97);
    --auth-theme-border: rgba(139, 92, 246, 0.25);
    --auth-theme-accent: #8b5cf6;
    --auth-theme-accent-hover: #a78bfa;
    --auth-theme-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --auth-theme-shadow: rgba(139, 92, 246, 0.4);
    --auth-theme-tab-active: rgba(99, 102, 241, 0.25);
}

/* 3. BroPro Times */
body[data-auth-theme="news"],
.auth-theme-news {
    --auth-theme-bg: #0f172a;
    --auth-theme-card-bg: rgba(15, 23, 42, 0.96);
    --auth-theme-border: rgba(225, 29, 72, 0.25);
    --auth-theme-accent: #f43f5e;
    --auth-theme-accent-hover: #fb7185;
    --auth-theme-gradient: linear-gradient(135deg, #e11d48 0%, #fb923c 100%);
    --auth-theme-shadow: rgba(225, 29, 72, 0.35);
    --auth-theme-tab-active: rgba(225, 29, 72, 0.22);
}

/* 4. Compassion Zone */
body[data-auth-theme="compassion"],
.auth-theme-compassion {
    --auth-theme-bg: #091a14;
    --auth-theme-card-bg: rgba(9, 26, 20, 0.96);
    --auth-theme-border: rgba(16, 185, 129, 0.28);
    --auth-theme-accent: #34d399;
    --auth-theme-accent-hover: #6ee7b7;
    --auth-theme-gradient: linear-gradient(135deg, #059669 0%, #f43f5e 100%);
    --auth-theme-shadow: rgba(16, 185, 129, 0.35);
    --auth-theme-tab-active: rgba(16, 185, 129, 0.22);
}

/* ----------------------------------------------------
   MODAL OVERLAY & BACKDROP
   ---------------------------------------------------- */
.bpro-auth-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    overflow-y: auto;
    animation: bproAuthFadeIn 0.22s ease-out;
}

.bpro-auth-overlay.active {
    display: flex;
}

/* ----------------------------------------------------
   MODAL CARD
   ---------------------------------------------------- */
.bpro-auth-card {
    background: var(--auth-theme-card-bg);
    border: 1px solid var(--auth-theme-border);
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    padding: 2.25rem 2rem;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8), 0 0 40px var(--auth-theme-shadow);
    position: relative;
    animation: bproAuthScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    color: #ffffff;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

.bpro-auth-card * {
    box-sizing: border-box;
}

/* Close Button (Top Right) */
.bpro-auth-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    z-index: 2;
}

.bpro-auth-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: scale(1.05);
}

/* ----------------------------------------------------
   PILL TABS (LOGIN / SIGN UP)
   ---------------------------------------------------- */
.bpro-auth-tabs-wrap {
    display: flex;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    padding: 4px;
    margin-bottom: 1.75rem;
    margin-top: 0.25rem;
}

.bpro-auth-tab-item {
    flex: 1;
    background: none;
    border: none;
    color: #94a3b8;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.bpro-auth-tab-item:hover:not(.active) {
    color: #ffffff;
}

.bpro-auth-tab-item.active {
    background: var(--auth-theme-tab-active);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

/* ----------------------------------------------------
   HEADER (EMOJI & TITLES)
   ---------------------------------------------------- */
.bpro-auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.bpro-auth-icon {
    font-size: 2.75rem;
    line-height: 1;
    margin-bottom: 0.75rem;
    display: inline-block;
    animation: bproWave 2s infinite ease-in-out;
    transform-origin: 70% 70%;
}

@keyframes bproWave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

.bpro-auth-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.4rem 0;
    letter-spacing: -0.02em;
}

.bpro-auth-subtitle {
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0;
}

/* ----------------------------------------------------
   GOOGLE SIGN IN BUTTON
   ---------------------------------------------------- */
.bpro-google-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    margin-bottom: 1.25rem;
}

.bpro-google-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.bpro-google-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.bpro-google-icon {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
}

/* ----------------------------------------------------
   DIVIDER
   ---------------------------------------------------- */
.bpro-auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
    text-transform: lowercase;
    margin: 1.25rem 0;
}

.bpro-auth-divider::before,
.bpro-auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bpro-auth-divider span {
    padding: 0 0.85rem;
}

/* ----------------------------------------------------
   FORM FIELDS & INPUTS
   ---------------------------------------------------- */
.bpro-auth-field {
    margin-bottom: 1.1rem;
}

.bpro-auth-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.bpro-auth-label {
    font-size: 0.825rem;
    font-weight: 600;
    color: #cbd5e1;
    display: block;
}

.bpro-auth-forgot-link {
    font-size: 0.8rem;
    color: var(--auth-theme-accent);
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s ease;
}

.bpro-auth-forgot-link:hover {
    color: var(--auth-theme-accent-hover);
    text-decoration: underline;
}

.bpro-auth-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.bpro-auth-input::placeholder {
    color: #64748b;
}

.bpro-auth-input:focus {
    border-color: var(--auth-theme-accent);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* ----------------------------------------------------
   ALERT / STATUS BANNERS
   ---------------------------------------------------- */
.bpro-auth-alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 1rem;
    display: none;
    animation: bproAuthFadeIn 0.2s ease;
}

.bpro-auth-alert.error {
    display: block;
    background: rgba(244, 63, 94, 0.14);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.bpro-auth-alert.success {
    display: block;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* ----------------------------------------------------
   PRIMARY ACTION SUBMIT BUTTON
   ---------------------------------------------------- */
.bpro-auth-submit-btn {
    width: 100%;
    background: var(--auth-theme-gradient);
    color: #ffffff;
    border: none;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--auth-theme-shadow);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.bpro-auth-submit-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 25px var(--auth-theme-shadow);
}

.bpro-auth-submit-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* ----------------------------------------------------
   FOOTER SWITCH
   ---------------------------------------------------- */
.bpro-auth-switch-prompt {
    text-align: center;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 1.35rem;
    margin-bottom: 0;
}

.bpro-auth-switch-prompt a {
    color: var(--auth-theme-accent);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.bpro-auth-switch-prompt a:hover {
    color: var(--auth-theme-accent-hover);
    text-decoration: underline;
}

/* ----------------------------------------------------
   ANIMATIONS
   ---------------------------------------------------- */
@keyframes bproAuthFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bproAuthScaleUp {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .bpro-auth-card {
        padding: 1.75rem 1.25rem;
        border-radius: 20px;
    }
    .bpro-auth-title {
        font-size: 1.4rem;
    }
}

/* ========================================================
   LIGHT MODE OVERRIDES FOR UNIVERSAL AUTH MODAL
   Ensures pristine visibility, contrast and beauty on light canvas
   ======================================================== */
[data-theme="light"] .bpro-auth-overlay {
    background: rgba(15, 23, 42, 0.5);
}

[data-theme="light"] .bpro-auth-card,
[data-theme="light"] body .bpro-auth-card {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 25px 80px rgba(15, 23, 42, 0.16), 0 0 35px var(--auth-theme-shadow);
    color: #090d16;
}

[data-theme="light"] .bpro-auth-close-btn {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.1);
    color: #64748b;
}

[data-theme="light"] .bpro-auth-close-btn:hover {
    background: rgba(15, 23, 42, 0.1);
    color: #090d16;
}

[data-theme="light"] .bpro-auth-tabs-wrap {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .bpro-auth-tab-item {
    color: #64748b;
}

[data-theme="light"] .bpro-auth-tab-item:hover:not(.active) {
    color: #090d16;
}

[data-theme="light"] .bpro-auth-tab-item.active {
    background: #ffffff;
    color: #090d16;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .bpro-auth-title {
    color: #090d16;
}

[data-theme="light"] .bpro-auth-subtitle {
    color: #475569;
}

[data-theme="light"] .bpro-auth-label {
    color: #1e293b;
}

[data-theme="light"] .bpro-auth-input {
    background: #f8fafc;
    border-color: rgba(15, 23, 42, 0.14);
    color: #090d16;
}

[data-theme="light"] .bpro-auth-input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .bpro-auth-input:focus {
    background: #ffffff;
}

[data-theme="light"] .bpro-auth-divider {
    color: #64748b;
}

[data-theme="light"] .bpro-auth-divider::before,
[data-theme="light"] .bpro-auth-divider::after {
    border-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .bpro-auth-switch-prompt {
    color: #64748b;
}

/* Native viewport and touch behavior for the universal authentication sheet. */
.bpro-auth-overlay {
    height: 100dvh;
    padding:
        max(1rem, env(safe-area-inset-top, 0px))
        max(1rem, env(safe-area-inset-right, 0px))
        max(1rem, env(safe-area-inset-bottom, 0px))
        max(1rem, env(safe-area-inset-left, 0px));
    overscroll-behavior: contain;
}

.bpro-auth-card {
    max-height: calc(100dvh - max(2rem, env(safe-area-inset-top, 0px)) - max(2rem, env(safe-area-inset-bottom, 0px)));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.bpro-auth-close-btn {
    width: 44px;
    height: 44px;
}

.bpro-auth-tab-item,
.bpro-google-btn,
.bpro-auth-submit-btn {
    min-height: 48px;
    touch-action: manipulation;
}

@media (max-width: 640px) {
    .bpro-auth-overlay {
        align-items: flex-end;
        padding-right: 0;
        padding-bottom: 0;
        padding-left: 0;
    }

    .bpro-auth-card {
        max-width: none;
        max-height: calc(100dvh - max(0.75rem, env(safe-area-inset-top, 0px)));
        padding: 1.5rem 1.15rem max(1.25rem, env(safe-area-inset-bottom, 0px));
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 24px 24px 0 0;
    }

    .bpro-auth-input {
        min-height: 48px;
        font-size: 1rem;
    }

    .bpro-auth-header {
        margin-bottom: 1.15rem;
    }

    .bpro-auth-icon {
        font-size: 2.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bpro-auth-overlay,
    .bpro-auth-card,
    .bpro-auth-icon,
    .bpro-auth-close-btn,
    .bpro-auth-tab-item,
    .bpro-google-btn,
    .bpro-auth-submit-btn {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
