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

<MudThemeProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudPopoverProvider />

<style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    html { scroll-behavior: smooth; }

    .auth-split-container {
        display: flex;
        min-height: 100vh;
        width: 100%;
        font-family: "Poppins", sans-serif;
    }

    .auth-left-panel {
        display: none;
        width: 50%;
        background: linear-gradient(135deg, #10B981 0%, #059669 50%, #047857 100%);
        align-items: center;
        justify-content: center;
        padding: 3rem;
        position: relative;
        overflow: hidden;
    }

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

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

    .auth-left-content {
        max-width: 28rem;
        z-index: 1;
        color: #ffffff;
    }

    .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);
        backdrop-filter: blur(8px);
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

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

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

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

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

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

    .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;
        background: rgba(255,255,255,0.2);
        border-radius: 0.25rem;
        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-label {
        font-weight: 600;
        font-size: 0.875rem;
        color: #ffffff;
    }

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

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

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

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

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

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

    .auth-right-panel {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1.5rem;
        background: #ffffff;
    }

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

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

    .auth-card-footer {
        text-align: center;
        margin-top: 1.5rem;
        font-size: 0.75rem;
        color: #94a3b8;
        font-weight: 600;
        letter-spacing: 0.025em;
    }

    .auth-mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem 1.5rem;
        background: linear-gradient(135deg, #10B981 0%, #059669 100%);
        color: #ffffff;
        margin: 0;
    }

    .auth-mobile-brand svg {
        width: 1.75rem;
        height: 1.75rem;
    }

    .auth-mobile-brand span {
        font-weight: 700;
        font-size: 1.125rem;
    }

    /* Form styles used by child components */
    .page-header {
        text-align: center;
        margin-bottom: 1.5rem;
    }

    .page-header h2 {
        font-size: 1.5rem;
        font-weight: 700;
        color: #1e293b;
    }

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

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

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

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

    .forgot-link:hover {
        color: #10B981;
        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: #10B981;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

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

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

    .btn-google:hover {
        border-color: #10B981;
        background: #ecfdf5;
    }

    .logout-container,
    .confirm-container {
        text-align: center;
        width: 100%;
    }

    .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;
        background: #ecfdf5;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

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

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

    .logout-desc,
    .confirm-desc {
        font-size: 0.875rem;
        color: #64748b;
        margin-bottom: 1.5rem;
    }

    @@media (min-width: 1024px) {
        .auth-left-panel {
            display: flex;
        }
        .auth-right-panel {
            width: 50%;
            padding: 3rem;
        }
        .auth-mobile-brand {
            display: none;
        }
    }

    @@media (max-width: 1023px) {
        .auth-right-panel {
            padding: 1rem;
        }
        .auth-card {
            border-radius: 0.75rem;
            padding: 1.5rem;
        }
    }
</style>

<div class="auth-split-container">
    <!-- Left Panel - Branding (hidden on mobile) -->
    <div class="auth-left-panel">
        <div class="auth-left-content">
            <div class="auth-brand-row" @onclick="NavigateToHome" style="cursor: pointer;">
                <div class="auth-brand-icon">
                    <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 00-3 3h15.75m-12.75-3h11.218c1.121-2.3 2.1-4.684 2.924-7.138a60.114 60.114 0 00-16.536-1.84M7.5 14.25L5.106 5.272M6 20.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm12.75 0a.75.75 0 11-1.5 0 .75.75 0 011.5 0z"/></svg>
                </div>
                <div>
                    <div class="auth-brand-name">@GlobalConsts.AppName</div>
                    <div class="auth-brand-sub">@GlobalConsts.AppTagline</div>
                </div>
            </div>
            <h2 class="auth-welcome-title">Welcome Back to<br/>Your SCM Platform</h2>
            <p class="auth-welcome-desc">A complete supply chain solution—seamless procurement to bill, streamlined sales to invoice.</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-label">Sales & Purchase</div>
                        <div class="auth-feature-sub">Quotation to payment, requisition to bill</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-label">Inventory & Warehouse</div>
                        <div class="auth-feature-sub">Product catalog, stock management, transfers</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-label">Customer & Vendor</div>
                        <div class="auth-feature-sub">Groups, categories, contacts, relationship tracking</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-label">Reports & Analytics</div>
                        <div class="auth-feature-sub">Sales, purchase, delivery and return reports</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Right Panel - Form Area -->
    <div class="auth-right-panel">
        <div class="auth-form-wrapper">
            <!-- Mobile Brand Strip -->
            <div class="auth-mobile-brand" @onclick="NavigateToHome" style="cursor: pointer;">
                <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 00-3 3h15.75m-12.75-3h11.218c1.121-2.3 2.1-4.684 2.924-7.138a60.114 60.114 0 00-16.536-1.84M7.5 14.25L5.106 5.272M6 20.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm12.75 0a.75.75 0 11-1.5 0 .75.75 0 011.5 0z"/></svg>
                <span>@GlobalConsts.AppName</span>
            </div>

            <!-- Form Card -->
            <div class="auth-card">
                @Body
            </div>

            <!-- Footer Copyright -->
            <div class="auth-card-footer">
                &copy; @DateTime.Now.Year @GlobalConsts.AppInitial. ALL RIGHTS RESERVED.
            </div>
        </div>
    </div>
</div>

@code {
    protected override void OnInitialized()
    {
        // Set MudTheme for emerald primary color
        var theme = new MudBlazor.MudTheme();
        theme.PaletteLight.Primary = "#10B981";
        theme.PaletteLight.Secondary = "#059669";
        theme.PaletteLight.AppbarBackground = "#10B981";
        theme.Typography.Default.FontFamily = new[] { "Poppins", "sans-serif" };
    }

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