<Window x:Class="CtrEditor.PopUps.ScaleConfigWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:CtrEditor.Converters"
        Title="Configurar Escala" 
        Height="280" 
        Width="450"
        WindowStartupLocation="CenterOwner"
        ResizeMode="NoResize">
    <Window.Resources>
        <converters:RegionalFloatConverter x:Key="RegionalFloatConverter"/>
    </Window.Resources>
    <Grid Margin="20">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- Título -->
        <TextBlock Grid.Row="0" 
                   Text="Configuración de Escala de Conversión" 
                   FontWeight="Bold" 
                   FontSize="14" 
                   Margin="0,0,0,15"/>

        <!-- Escala actual -->
        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,10">
            <TextBlock Text="Escala actual: " VerticalAlignment="Center" Width="120"/>
            <TextBlock VerticalAlignment="Center" FontWeight="Bold">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} m/pixel">
                        <Binding Path="CurrentScale" Converter="{StaticResource RegionalFloatConverter}"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </StackPanel>

        <!-- Nueva escala -->
        <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,10">
            <TextBlock Text="Nueva escala: " VerticalAlignment="Center" Width="120"/>
            <TextBox x:Name="ScaleTextBox" 
                     Text="{Binding NewScale, Converter={StaticResource RegionalFloatConverter}, UpdateSourceTrigger=PropertyChanged}" 
                     Width="100" 
                     VerticalAlignment="Center"
                     Margin="0,0,5,0"/>
            <TextBlock Text="m/pixel" VerticalAlignment="Center"/>
        </StackPanel>

        <!-- Presets -->
        <StackPanel Grid.Row="3" Orientation="Vertical" Margin="0,0,0,15">
            <TextBlock Text="Presets comunes:" FontWeight="SemiBold" Margin="0,0,0,5"/>
            <WrapPanel>
                <Button Content="1:1 (0.01)" Command="{Binding SetPresetCommand}" CommandParameter="0.01" Margin="0,0,5,5"/>
                <Button Content="1:10 (0.001)" Command="{Binding SetPresetCommand}" CommandParameter="0.001" Margin="0,0,5,5"/>
                <Button Content="1:100 (0.0001)" Command="{Binding SetPresetCommand}" CommandParameter="0.0001" Margin="0,0,5,5"/>
                <Button Content="1 px = 1 cm (0.01)" Command="{Binding SetPresetCommand}" CommandParameter="0.01" Margin="0,0,5,5"/>
                <Button Content="1 px = 1 mm (0.001)" Command="{Binding SetPresetCommand}" CommandParameter="0.001" Margin="0,0,5,5"/>
            </WrapPanel>
        </StackPanel>

        <!-- Información de ayuda -->
        <Border Grid.Row="5" 
                Background="LightYellow" 
                BorderBrush="Orange" 
                BorderThickness="1" 
                Padding="10" 
                Margin="0,0,0,15">
            <StackPanel>
                <TextBlock Text="Información:" FontWeight="Bold" Margin="0,0,0,5"/>
                <TextBlock TextWrapping="Wrap">
                    <Run Text="La escala define cuántos metros representa cada píxel en el canvas."/>
                    <LineBreak/>
                    <Run Text="• Valores menores = objetos más pequeños en pantalla"/>
                    <LineBreak/>
                    <Run Text="• Valores mayores = objetos más grandes en pantalla"/>
                    <LineBreak/>
                    <Run Text="• Ejemplo: 0.01 significa que 1 píxel = 1 centímetro"/>
                    <LineBreak/>
                    <Run Text="• Los cambios se aplican automáticamente después de 0.5 segundos"/>
                </TextBlock>
            </StackPanel>
        </Border>

        <!-- Botones -->
        <StackPanel Grid.Row="6" 
                    Orientation="Horizontal" 
                    HorizontalAlignment="Right">
            <Button Content="Aplicar" 
                    Command="{Binding ApplyCommand}"
                    Width="80" 
                    Height="30" 
                    Margin="0,0,10,0"/>
            <Button Content="Aceptar" 
                    Command="{Binding AcceptCommand}"
                    Width="80" 
                    Height="30" 
                    Margin="0,0,10,0" 
                    IsDefault="True"/>
            <Button Content="Cancelar" 
                    Command="{Binding CancelCommand}"
                    Width="80" 
                    Height="30" 
                    IsCancel="True"/>
        </StackPanel>
    </Grid>
</Window> 