<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="LSFE.MobApp.Pages.CoveragePlan.ViewDoctorPage"
              xmlns:vm="clr-namespace:LSFE.MobApp.ViewModels.Coverage"
             x:DataType="vm:ViewDoctorVM"
             Title="Doctor Details"
             BackgroundColor="#F9FAFB">
    <ScrollView>
        <VerticalStackLayout Padding="20" Spacing="20">

            <!-- Header Card with Avatar -->
            <Border BackgroundColor="White" 
                    Stroke="#E5E7EB" 
                    StrokeThickness="1"
                    StrokeShape="RoundRectangle 16"
                    Padding="24">
                <Grid RowDefinitions="Auto,Auto" ColumnDefinitions="Auto,*,Auto">
                    <!-- Large Avatar -->
                    <Border Grid.Row="0" 
                            Grid.RowSpan="2"
                            Grid.Column="0"
                            BackgroundColor="#E0F2FE" 
                            WidthRequest="80" 
                            HeightRequest="80"
                            StrokeShape="RoundRectangle 40"
                            StrokeThickness="0"
                            VerticalOptions="Center"
                            Margin="0,0,20,0">
                        <Label Text="👨‍⚕️" 
                               FontSize="48" 
                               HorizontalOptions="Center" 
                               VerticalOptions="Center"/>
                    </Border>

                    <!-- Name and Specialization -->
                    <VerticalStackLayout Grid.Row="0" 
                                         Grid.Column="1" 
                                         Spacing="6"
                                         VerticalOptions="Center">
                        <Label Text="{Binding FullName}" 
                               FontSize="24" 
                               FontAttributes="Bold" 
                               TextColor="#111827"/>
                        <Label Text="{Binding Specialization}" 
                               FontSize="16" 
                               TextColor="#6B7280"/>
                    </VerticalStackLayout>

                    <!-- Status Badge -->
                    <Border Grid.Row="0" 
                            Grid.Column="2" 
                            BackgroundColor="{Binding StatusBackgroundColor}"
                            Padding="16,8"
                            StrokeShape="RoundRectangle 12"
                            StrokeThickness="0"
                            VerticalOptions="Start">
                        <Label Text="{Binding StatusText}" 
                               TextColor="{Binding StatusTextColor}" 
                               FontSize="13" 
                               FontAttributes="Bold"/>
                    </Border>
                </Grid>
            </Border>

            <!-- Contact Information -->
            <Border BackgroundColor="White" 
                    Stroke="#E5E7EB" 
                    StrokeThickness="1"
                    StrokeShape="RoundRectangle 12"
                    Padding="20">
                <VerticalStackLayout Spacing="20">
                    <Label Text="Contact Information" 
                           FontSize="18" 
                           FontAttributes="Bold" 
                           TextColor="#111827"/>

                    <!-- Email -->
                    <Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#EFF6FF"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="📧" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Email Address" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding EmailAddress}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                        <Button Grid.Column="2"
                                Text="📋"
                                BackgroundColor="Transparent"
                                FontSize="20"
                                Command="{Binding CopyEmailCommand}"
                                ToolTipProperties.Text="Copy Email"
                                Padding="8"/>
                    </Grid>

                    <!-- Phone -->
                    <Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#F0FDF4"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="📱" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Phone Number" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding PhoneNo}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                        <Button Grid.Column="2"
                                Text="📞"
                                BackgroundColor="Transparent"
                                FontSize="20"
                                Command="{Binding CallPhoneCommand}"
                                ToolTipProperties.Text="Call"
                                Padding="8"/>
                    </Grid>

                    <!-- Address -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12" IsVisible="{Binding HasAddress}">
                        <Border Grid.Column="0"
                                BackgroundColor="#FEF3C7"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="📍" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Address" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding Address}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   LineBreakMode="WordWrap"/>
                        </VerticalStackLayout>
                    </Grid>
                </VerticalStackLayout>
            </Border>

            <!-- Professional Details -->
            <Border BackgroundColor="White" 
                    Stroke="#E5E7EB" 
                    StrokeThickness="1"
                    StrokeShape="RoundRectangle 12"
                    Padding="20">
                <VerticalStackLayout Spacing="20">
                    <Label Text="Professional Details" 
                           FontSize="18" 
                           FontAttributes="Bold" 
                           TextColor="#111827"/>

                    <!-- License Number -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#DBEAFE"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="🆔" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="License Number" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding LicenseNo}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                    </Grid>

                    <!-- Institution -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12" IsVisible="{Binding HasInstitution}">
                        <Border Grid.Column="0"
                                BackgroundColor="#FCE7F3"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="🏥" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Institution" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding InstitutionName}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                    </Grid>

                    <!-- Max Visits -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#E0E7FF"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="📅" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Maximum Visits Per Day" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding MaxVisit}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                    </Grid>

                    <!-- Birth Date -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#FEE2E2"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="🎂" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Birth Date" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding BirthDateFormatted}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                    </Grid>

                    <!-- Created Date -->
                    <Grid ColumnDefinitions="Auto,*" ColumnSpacing="12">
                        <Border Grid.Column="0"
                                BackgroundColor="#F3F4F6"
                                WidthRequest="44"
                                HeightRequest="44"
                                StrokeShape="RoundRectangle 22"
                                StrokeThickness="0">
                            <Label Text="🕐" 
                                   FontSize="22" 
                                   HorizontalOptions="Center" 
                                   VerticalOptions="Center"/>
                        </Border>
                        <VerticalStackLayout Grid.Column="1" Spacing="4" VerticalOptions="Center">
                            <Label Text="Created Date" 
                                   FontSize="12" 
                                   TextColor="#6B7280"/>
                            <Label Text="{Binding CreatedDateFormatted}" 
                                   FontSize="15" 
                                   TextColor="#111827"
                                   FontAttributes="Bold"/>
                        </VerticalStackLayout>
                    </Grid>
                </VerticalStackLayout>
            </Border>

            <!-- Action Button -->
            <Button Text="Close"
                    BackgroundColor="#0EA5E9"
                    TextColor="White"
                    CornerRadius="12"
                    Padding="0,16"
                    FontSize="16"
                    FontAttributes="Bold"
                    Command="{Binding CloseCommand}"
                    Margin="0,10,0,20"/>
        </VerticalStackLayout>
    </ScrollView>
</ContentPage>