@using Indotalent.Shared.Consts
@inherits LayoutComponentBase
@inject NavigationManager Navigation

<MudThemeProvider Theme="_theme" />
<MudDialogProvider />
<MudSnackbarProvider />
<MudPopoverProvider />

<style>
    /* ===== FONT ===== */
    @@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;450;500;600;700;800&display=swap');

    * { margin: 0; padding: 0; box-sizing: border-box; }

    /* ===== SPLIT CONTAINER ===== */
    .auth-split-container {
        display: flex;
        min-height: 100vh;
        width: 100vw;
        overflow: hidden;
        position: relative;
    }

    /* ===== LEFT PANEL - GRADIENT BRANDING ===== */
    .auth-left-panel {
        width: 50%;
        background: linear-gradient(135deg, #6366F1 0%, #5558E6 30%, #4F46E5 60%, #4338CA 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 3rem;
        position: relative;
        overflow: hidden;
    }

    .auth-left-panel::before {
        content: '';
        position: absolute;
        top: -120px;
        right: -120px;
        width: 400px;
        height: 400px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.04);
        pointer-events: none;
    }

    .auth-left-panel::after {
        content: '';
        position: absolute;
        bottom: -80px;
        left: -80px;
        width: 300px;
        height: 300px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.04);
        pointer-events: none;
    }

    .auth-left-content {
        max-width: 28rem;
        position: relative;
        z-index: 1;
    }

    .auth-brand-row {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 2rem;
    }

    .auth-brand-icon {
        width: 3.5rem;
        height: 3.5rem;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(8px);
        cursor: pointer;
        transition: background 0.2s;
    }

    .auth-brand-icon:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .auth-brand-icon svg {
        width: 2rem;
        height: 2rem;
        color: #ffffff;
    }

    .auth-brand-name {
        color: #ffffff;
        font-size: 1.5rem;
        font-weight: 700;
    }

    .auth-brand-sub {
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.8125rem;
    }

    .auth-welcome-title {
        color: #ffffff;
        font-size: 1.875rem;
        font-weight: 700;
        line-height: 1.25;
        margin-bottom: 1rem;
    }

    .auth-welcome-desc {
        color: rgba(255, 255, 255, 0.8);
        font-size: 0.875rem;
        line-height: 1.6;
        margin-bottom: 2rem;
    }

    .auth-feature-list {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2.5rem;
    }

    .auth-feature-item {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .auth-feature-check {
        width: 1.25rem;
        height: 1.25rem;
        border-radius: 0.25rem;
        background: rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        margin-top: 0.125rem;
    }

    .auth-feature-check svg {
        width: 0.75rem;
        height: 0.75rem;
        color: #ffffff;
    }

    .auth-feature-text-title {
        color: #ffffff;
        font-size: 0.875rem;
        font-weight: 600;
    }

    .auth-feature-text-desc {
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.75rem;
        margin-top: 0.125rem;
    }

    .auth-support-card {
        padding: 1rem;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .auth-support-avatar {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .auth-support-avatar svg {
        width: 1.25rem;
        height: 1.25rem;
        color: #ffffff;
    }

    .auth-support-title {
        color: #ffffff;
        font-size: 0.875rem;
        font-weight: 600;
    }

    .auth-support-desc {
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.75rem;
    }

    /* ===== RIGHT PANEL - FORM AREA ===== */
    .auth-right-panel {
        width: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1.5rem;
        background: #ffffff;
    }

    .auth-form-wrapper {
        width: 100%;
        max-width: 28rem;
    }

    .auth-card {
        border-radius: 1rem !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04) !important;
        background: #ffffff !important;
    }

    .auth-card-footer {
        margin-top: 1rem;
        text-align: center;
        font-size: 0.75rem;
        color: #94a3b8;
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    /* ===== MOBILE BRAND STRIP ===== */
    .auth-mobile-brand {
        display: none;
        text-align: center;
        padding: 1.25rem 1rem 0.75rem;
        background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    }

    .auth-mobile-brand-inner {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }

    .auth-mobile-brand-icon {
        width: 2rem;
        height: 2rem;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .auth-mobile-brand-icon svg {
        width: 1.125rem;
        height: 1.125rem;
        color: #ffffff;
    }

    .auth-mobile-brand-name {
        color: #ffffff;
        font-size: 1.125rem;
        font-weight: 700;
    }

    /* ===== RESPONSIVE ===== */
    @@media (max-width: 1023px) {
        .auth-left-panel {
            display: none;
        }

        .auth-right-panel {
            width: 100%;
            padding: 1rem;
            align-items: flex-start;
            padding-top: 0;
        }

        .auth-form-wrapper {
            max-width: 100%;
        }

        .auth-mobile-brand {
            display: block;
        }

        .auth-card {
            border-radius: 0.75rem !important;
        }
    }

    @@media (min-width: 1280px) {
        .auth-left-panel {
            padding: 4rem;
        }

        .auth-right-panel {
            padding: 2.5rem;
        }
    }

    /* ===== PAGE COMPONENTS SHARED STYLES ===== */
    .page-header {
        text-align: center;
        margin-bottom: 1.5rem;
    }

    .page-header h2 {
        font-size: 1.5rem;
        font-weight: 700;
        color: #0f172a;
        margin-bottom: 0.25rem;
    }

    .page-header p {
        font-size: 0.875rem;
        color: #64748b;
    }

    .form-label {
        display: block;
        font-size: 0.8125rem;
        font-weight: 600;
        color: #475569;
        margin-bottom: 0.25rem;
    }

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

    .forgot-link {
        font-size: 0.8125rem;
        color: #64748b;
        text-decoration: none;
        cursor: pointer;
        transition: color 0.2s;
    }

    .forgot-link:hover {
        color: #6366F1;
        text-decoration: underline;
    }

    .remember-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .divider-or {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin: 1.5rem 0;
    }

    .divider-or::before,
    .divider-or::after {
        content: '';
        flex: 1;
        height: 1px;
        background: #e2e8f0;
    }

    .divider-or span {
        font-size: 0.75rem;
        color: #94a3b8;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .auth-link {
        color: #6366F1;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        transition: color 0.2s;
    }

    .auth-link:hover {
        color: #4F46E5;
        text-decoration: underline;
    }

    .btn-google {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.625rem 1rem;
        background: transparent;
        color: #475569;
        font-size: 0.875rem;
        font-weight: 500;
        border-radius: 0.5rem;
        border: 1.5px solid #e2e8f0;
        transition: all 0.2s;
        cursor: pointer;
        width: 100%;
        font-family: "Poppins", sans-serif;
    }

    .btn-google:hover {
        border-color: #c4b5fd;
        background: #f5f3ff;
    }

    /* ===== LOGOUT / CONFIRM STYLES ===== */
    .logout-container,
    .confirm-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1.5rem 0;
    }

    .logout-icon-wrapper,
    .confirm-icon-wrapper {
        display: flex;
        justify-content: center;
        margin-bottom: 1.5rem;
    }

    .logout-icon-circle,
    .confirm-icon-circle {
        width: 5rem;
        height: 5rem;
        border-radius: 50%;
        background: rgba(99, 102, 241, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .logout-icon-circle svg,
    .confirm-icon-circle svg {
        width: 2.5rem;
        height: 2.5rem;
        color: #6366F1;
    }

    .logout-title,
    .confirm-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: #0f172a;
        margin-bottom: 0.5rem;
    }

    .logout-desc,
    .confirm-desc {
        font-size: 0.875rem;
        color: #64748b;
        margin-bottom: 1.5rem;
        line-height: 1.5;
    }
</style>

<div class="auth-split-container">

    @* Left Panel - Branding *@
    <div class="auth-left-panel">
        <div class="auth-left-content">
            <div class="auth-brand-row">
                <div class="auth-brand-icon" @onclick="NavigateToHome">
                    <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
                    </svg>
                </div>
                <div>
                    <div class="auth-brand-name">Blazor CRM</div>
                    <div class="auth-brand-sub">Complete Source Code Solution</div>
                </div>
            </div>

            <h2 class="auth-welcome-title">Your Business,<br/>Your CRM, Your Way</h2>
            <p class="auth-welcome-desc">A complete, end-to-end CRM with full source code. Manage your leads, sales, purchases, and inventory — all in one place.</p>

            <div class="auth-feature-list">
                <div class="auth-feature-item">
                    <div class="auth-feature-check">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/>
                        </svg>
                    </div>
                    <div>
                        <div class="auth-feature-text-title">Pipeline & Lead Management</div>
                        <div class="auth-feature-text-desc">Campaigns, budgets, leads, contacts & sales team</div>
                    </div>
                </div>
                <div class="auth-feature-item">
                    <div class="auth-feature-check">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/>
                        </svg>
                    </div>
                    <div>
                        <div class="auth-feature-text-title">Sales & Purchase</div>
                        <div class="auth-feature-text-desc">Orders, invoices, payments & full procurement</div>
                    </div>
                </div>
                <div class="auth-feature-item">
                    <div class="auth-feature-check">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/>
                        </svg>
                    </div>
                    <div>
                        <div class="auth-feature-text-title">Inventory & Reporting</div>
                        <div class="auth-feature-text-desc">Products, warehouses, stock counts & full reports</div>
                    </div>
                </div>
            </div>

            <div class="auth-support-card">
                <div class="auth-support-avatar">
                    <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"/>
                    </svg>
                </div>
                <div>
                    <div class="auth-support-title">Production-Ready Source Code</div>
                    <div class="auth-support-desc">Built with .NET 10, Blazor Server & MudBlazor 9</div>
                </div>
            </div>
        </div>
    </div>

    @* Right Panel - Form Area *@
    <div class="auth-right-panel">

        @* Mobile Brand Strip *@
        <div style="width: 100%; display: flex; flex-direction: column;">
            <div class="auth-mobile-brand">
                <div class="auth-mobile-brand-inner">
                    <div class="auth-mobile-brand-icon">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
                        </svg>
                    </div>
                    <span class="auth-mobile-brand-name">@GlobalConsts.AppInitial</span>
                </div>
            </div>

            <div class="auth-form-wrapper" style="margin: 0 auto; width: 100%; max-width: 28rem; padding: 0 0.25rem;">
                <MudCard Elevation="0" Class="auth-card pa-2">
                    <MudCardContent Class="pa-6">
                        @Body
                    </MudCardContent>
                </MudCard>

                <div class="auth-card-footer">
                    © @DateTime.Now.Year @GlobalConsts.AppInitial. ALL RIGHTS RESERVED.
                </div>
            </div>
        </div>
    </div>

</div>

@code {
    private MudTheme _theme = new()
    {
        PaletteLight = new PaletteLight()
        {
            Primary = "#6366F1",
            Secondary = "#818CF8",
            Tertiary = "#A5B4FC",
            AppbarBackground = "#6366F1",
            DrawerBackground = "#F8FAFC",
            Background = "#F8FAFC",
            Surface = "#FFFFFF",
            TextPrimary = "#1E293B",
            TextSecondary = "#64748B",
            Divider = "#E2E8F0",
            DividerLight = "#F1F5F9",
        },
        Typography = new Typography()
        {
            Default = new DefaultTypography()
            {
                FontFamily = new[] { "Poppins", "sans-serif" }
            }
        }
    };

    private void NavigateToHome()
    {
        Navigation.NavigateTo("/", forceLoad: true);
    }
}