$C = "../Common.ui";
$Sounds = "../Sounds.ui";

$C.@PageOverlay #MainPage {
  Anchor: (Top: 130);
}

Group #FormContainer {
  LayoutMode: Top;

  $C.@DecoratedContainer {
    Anchor: (Left: 50, Top: 170, Width: 420);

    #Title {
      $C.@Title {
        @Text = %server.customUI.objImport.title;
      }
    }

    #Content {
      LayoutMode: Top;
      Padding: (Full: 16);

      Label {
        Anchor: (Bottom: 12);
        Style: (...$C.@DefaultLabelStyle, Wrap: true, FontSize: 14, TextColor: #94969a);
        Text: %server.customUI.objImport.description;
      }

      Group {
        LayoutMode: Top;
        Anchor: (Bottom: 8);
        Background: (TexturePath: "../Common/ContainerPanelPatch.png", Border: 4);
        Padding: (Full: 12);

        Group #ObjPath {
          LayoutMode: Top;
          Anchor: (Bottom: 8);

          Label {
            Text: %server.customUI.objImport.filePath;
            Anchor: (Bottom: 4);
            Style: $C.@DefaultLabelStyle;
          }

          Group {
            LayoutMode: Left;
            Anchor: (Height: 35);

            $C.@TextField #Input {
              @Anchor = (Left: 0, Right: 8);
              FlexWeight: 1;
              MaxLength: 1024;
              PlaceholderText: "imports/models/model.obj";
            }

            $C.@SecondaryTextButton #BrowseButton {
              @Anchor = (Width: 140);
              Text: %server.customUI.browse;
            }
          }
        }

        Group #SizeModeInput {
          LayoutMode: Left;
          Anchor: (Top: 8, Bottom: 8, Height: 35);

          Label {
            Text: %server.customUI.objImport.sizeMode;
            Anchor: (Width: 120);
            Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center);
          }

          $C.@DropdownBox #Input {
            Anchor: (Width: 160, Height: $C.@DropdownBoxHeight);
          }
        }

        Group #HeightInput {
          LayoutMode: Left;
          Anchor: (Bottom: 8, Height: 35);
          Visible: true;

          Label {
            Text: %server.customUI.objImport.height;
            Anchor: (Width: 120);
            Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center);
          }

          $C.@NumberField #Input {
            @Anchor = (Width: 100);
            Format: (
              MaxDecimalPlaces: 0,
              Step: 1,
              MinValue: 1,
              MaxValue: 256
            );
          }
        }

        Group #ScaleInput {
          LayoutMode: Left;
          Anchor: (Bottom: 8, Height: 35);
          Visible: false;

          Label {
            Text: %server.customUI.objImport.scale;
            Anchor: (Width: 120);
            Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center);
          }

          $C.@NumberField #Input {
            @Anchor = (Width: 100);
            Format: (
              MaxDecimalPlaces: 2,
              Step: 0.1,
              MinValue: 0.01,
              MaxValue: 100
            );
          }
        }

        Group #BlockPattern {
          LayoutMode: Top;
          Anchor: (Bottom: 8);

          Label {
            Text: %server.customUI.objImport.blockPattern;
            Anchor: (Bottom: 4);
            Style: $C.@DefaultLabelStyle;
          }

          $C.@TextField #Input {
            @Anchor = (Left: 0);
            MaxLength: 512;
            PlaceholderText: "Rock_Stone or 50%Rock_Stone,50%Rock_Basalt";
          }
        }

        Group #FillModeContainer {
          LayoutMode: Left;
          Anchor: (Top: 4, Bottom: 8);

          $C.@CheckBoxWithLabel #FillModeCheckbox {
            @Text = %server.customUI.objImport.fillSolid;
            @Checked = true;
          }
        }

        Group #UseMaterialsContainer {
          LayoutMode: Left;
          Anchor: (Top: 4, Bottom: 8);

          $C.@CheckBoxWithLabel #UseMaterialsCheckbox {
            @Text = %server.customUI.objImport.useMaterials;
            @Checked = true;
          }
        }

        Group #AutoDetectTexturesContainer {
          LayoutMode: Left;
          Anchor: (Top: 4, Bottom: 8);

          $C.@CheckBoxWithLabel #AutoDetectTexturesCheckbox {
            @Text = %server.customUI.objImport.autoDetectTextures;
            @Checked = false;
          }
        }

        Group #OriginInput {
          LayoutMode: Left;
          Anchor: (Top: 4, Bottom: 8, Height: 35);

          Label {
            Text: %server.customUI.objImport.origin;
            Anchor: (Width: 120);
            Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center);
          }

          $C.@DropdownBox #Input {
            Anchor: (Width: 160, Height: $C.@DropdownBoxHeight);
          }
        }

        Group #RotationInput {
          LayoutMode: Left;
          Anchor: (Top: 4, Height: 35);

          Label {
            Text: %server.customUI.objImport.upAxis;
            Anchor: (Width: 120);
            Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center);
          }

          $C.@DropdownBox #Input {
            Anchor: (Width: 160, Height: $C.@DropdownBoxHeight);
          }
        }
      }

      Label #StatusText {
        Anchor: (Vertical: 8);
        Style: (...$C.@DefaultLabelStyle, Wrap: true, TextColor: #cfd8e3, FontSize: 14);
        Visible: false;
      }

      Group {
        LayoutMode: Top;
        Anchor: (Top: 6);

        $C.@TextButton #ImportButton {
          Text: %server.customUI.objImport.importButton;
        }
      }
    }
  }
}

// Browser modal page for file selection
$C.@PageOverlay #BrowserPage {
  LayoutMode: Middle;
  Visible: false;

  $C.@DecoratedContainer {
    Anchor: (Width: 600, Height: 550);

    #Title {
      $C.@Title {
        @Text = %server.customUI.objImport.browserTitle;
      }
    }

    #Content {
      LayoutMode: Top;
      Padding: (Full: 16);

      // Current path display
      Label #CurrentPath {
        Anchor: (Bottom: 8, Horizontal: 4);
        Style: (...$C.@DefaultLabelStyle, FontSize: 12, TextColor: #6a7d8f);
        Text: "/";
      }

      // Browser content (search + file list)
      Group #BrowserContent {
        FlexWeight: 1;

        Group {
          LayoutMode: Top;

          Group {
            LayoutMode: Left;
            Anchor: (Bottom: 10, Height: $C.@DropdownBoxHeight);

            $C.@TextField #SearchInput {
              @Anchor = (Left: 0);
              FlexWeight: 1;
              PlaceholderText: %server.customUI.objImport.searchPlaceholder;
            }
          }

          Group #FileList {
            FlexWeight: 1;
            LayoutMode: TopScrolling;
            ScrollbarStyle: $C.@DefaultScrollbarStyle;
          }
        }
      }

      Group #BrowserButtons {
        LayoutMode: Center;
        Anchor: (Top: 12);

        $C.@TextButton #SelectButton {
          @Sounds = $Sounds.@SaveSettings;
          @Anchor = (Right: 4);
          Text: %server.customUI.select;
          FlexWeight: 1;
        }

        $C.@SecondaryTextButton #CancelButton {
          @Sounds = $Sounds.@ButtonsCancel;
          @Anchor = (Left: 4);
          Text: %server.customUI.cancel;
          FlexWeight: 1;
        }
      }
    }
  }
}

$C.@BackButton {}
