<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="using:ClaudeDo.Ui.ViewModels"
        xmlns:islands="using:ClaudeDo.Ui.Views.Islands"
        x:Class="ClaudeDo.Ui.Views.MainWindow"
        x:DataType="vm:IslandsShellViewModel"
        Title="ClaudeDo"
        Width="1280" Height="820" MinWidth="780" MinHeight="600"
        Background="{DynamicResource VoidBrush}"
        Icon="avares://ClaudeDo.Ui/Assets/ClaudeTask.ico"
        CanResize="True"
        SystemDecorations="BorderOnly"
        ExtendClientAreaToDecorationsHint="True"
        ExtendClientAreaTitleBarHeightHint="-1">
  <Window.KeyBindings>
    <KeyBinding Gesture="OemQuestion" Command="{Binding FocusSearchCommand}"/>
    <KeyBinding Gesture="Shift+OemQuestion" Command="{Binding FocusSearchCommand}"/>
    <KeyBinding Gesture="Ctrl+N" Command="{Binding FocusAddTaskCommand}"/>
  </Window.KeyBindings>
  <Grid RowDefinitions="36,*,22">
    <!-- Custom title bar -->
    <Border Grid.Row="0"
            Background="{DynamicResource DeepBrush}"
            BorderBrush="{DynamicResource LineBrush}"
            BorderThickness="0,0,0,1">
      <Grid ColumnDefinitions="Auto,*,Auto">

        <!-- Left: brand block -->
        <StackPanel Grid.Column="0" Orientation="Horizontal" Spacing="8"
                    VerticalAlignment="Center" Margin="14,0,0,0">
          <!-- App icon (matches taskbar) -->
          <Image Source="avares://ClaudeDo.Ui/Assets/ClaudeTask.ico"
                 Width="16" Height="16"
                 VerticalAlignment="Center"
                 RenderOptions.BitmapInterpolationMode="HighQuality"/>
          <!-- CLAUDEDO label -->
          <TextBlock Classes="title-brand-name"
                     Text="CLAUDEDO"
                     FontFamily="{DynamicResource MonoFont}"
                     FontSize="11"
                     Foreground="{DynamicResource TextBrush}"
                     LetterSpacing="1.4"
                     VerticalAlignment="Center"/>
          <!-- separator dot -->
          <TextBlock Text="·"
                     FontFamily="{DynamicResource MonoFont}"
                     FontSize="11"
                     Foreground="{DynamicResource TextFaintBrush}"
                     VerticalAlignment="Center"/>
          <!-- current list name -->
          <TextBlock Text="{Binding Lists.SelectedList.Name, Converter={StaticResource UpperCase}}"
                     FontFamily="{DynamicResource MonoFont}"
                     FontSize="11"
                     Foreground="{DynamicResource TextDimBrush}"
                     LetterSpacing="1.4"
                     VerticalAlignment="Center"/>
        </StackPanel>

        <!-- Middle: draggable strip -->
        <Border Grid.Column="1" Background="Transparent"
                PointerPressed="OnTitleBarPressed" />

        <!-- Right: window controls -->
        <StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="0"
                    VerticalAlignment="Center" Margin="0,0,4,0">
          <Button Classes="title-ctrl" Click="OnMinimize">
            <PathIcon Data="{StaticResource Icon.WinMin}" Width="10" Height="10"/>
          </Button>
          <Button Classes="title-ctrl" Click="OnToggleMax">
            <PathIcon Data="{StaticResource Icon.WinMax}" Width="10" Height="10"/>
          </Button>
          <Button Classes="title-ctrl close" Click="OnClose">
            <PathIcon Data="{StaticResource Icon.WinClose}" Width="10" Height="10"/>
          </Button>
        </StackPanel>

      </Grid>
    </Border>

    <!-- Background gradient layer -->
    <Border Grid.Row="1">
      <Border.Background>
        <RadialGradientBrush Center="50%,50%" GradientOrigin="50%,50%" RadiusX="70%" RadiusY="70%">
          <GradientStop Offset="0"   Color="{StaticResource DeepColor}" />
          <GradientStop Offset="1"   Color="{StaticResource VoidColor}" />
        </RadialGradientBrush>
      </Border.Background>
    </Border>

    <!-- Three islands -->
    <Grid Grid.Row="1" Margin="7" ColumnDefinitions="260,*,320">
      <Border Grid.Column="0" Classes="island" Margin="7">
        <islands:ListsIslandView DataContext="{Binding Lists}"/>
      </Border>
      <Border Grid.Column="1" Classes="island" Margin="7">
        <islands:TasksIslandView DataContext="{Binding Tasks}"/>
      </Border>
      <Border Grid.Column="2" Classes="island" Margin="7"
              IsVisible="{Binding ShowDetails}">
        <islands:DetailsIslandView DataContext="{Binding Details}"/>
      </Border>
    </Grid>

    <!-- Footer: connection status -->
    <Border Grid.Row="2"
            Background="{DynamicResource DeepBrush}"
            BorderBrush="{DynamicResource LineBrush}"
            BorderThickness="0,1,0,0">
      <StackPanel Orientation="Horizontal" Spacing="7"
                  VerticalAlignment="Center" Margin="14,0">
        <Ellipse Width="7" Height="7" Fill="#4CAF50"
                 IsVisible="{Binding Worker.IsConnected}"/>
        <Ellipse Width="7" Height="7" Fill="#FFA726"
                 IsVisible="{Binding Worker.IsReconnecting}"/>
        <Ellipse Width="7" Height="7" Fill="#EF5350"
                 IsVisible="{Binding IsOffline}"/>
        <TextBlock Text="{Binding ConnectionText, Converter={StaticResource UpperCase}}"
                   FontFamily="{DynamicResource MonoFont}"
                   FontSize="10"
                   LetterSpacing="1.4"
                   Foreground="{DynamicResource TextDimBrush}"
                   VerticalAlignment="Center"/>
        <TextBlock Text="·"
                   FontFamily="{DynamicResource MonoFont}"
                   FontSize="10"
                   Foreground="{DynamicResource TextFaintBrush}"
                   VerticalAlignment="Center"/>
        <TextBlock Text="WORKER"
                   FontFamily="{DynamicResource MonoFont}"
                   FontSize="10"
                   LetterSpacing="1.4"
                   Foreground="{DynamicResource TextFaintBrush}"
                   VerticalAlignment="Center"/>
      </StackPanel>
    </Border>
  </Grid>
</Window>
