<?xml version="1.0" encoding="UTF-8"?>
<window>
    <onload condition="Skin.HasSetting(MilionarDefaultsV1)">SetProperty(milionar.logo.tint,$VAR[MilionarLogoTint],home)</onload>
    <onload condition="!Skin.HasSetting(MilionarDefaultsV1)">SetProperty(milionar.logo.tint,FFFFFFFF,home)</onload>
    <onload condition="Skin.HasSetting(MilionarDefaultsV1)">SetProperty(milionar.logo.wordmark,$VAR[MilionarWordmark],home)</onload>
    <onload condition="!Skin.HasSetting(MilionarDefaultsV1)">SetProperty(milionar.logo.wordmark,FFFFF5E5,home)</onload>

    <defaultcontrol always="true">2000</defaultcontrol>
    <onload>SetProperty(WCS.AIChat.Title,AI Chat Doporučení)</onload>
    <onload>SetProperty(WCS.AIChat.Status,Připraven)</onload>
    <!-- Default fanart fallback -->
    <onload>SetProperty(WCS.AIPreview.Fanart,special://home/addons/plugin.video.milionar/resources/media/fanart_fallback.jpg)</onload>
    
    <!-- Sofistikované animace při otevření/zavření dialogu -->
    <animation effect="fade" start="0" end="100" time="400" tween="cubic" easing="out">WindowOpen</animation>
    <animation effect="fade" start="100" end="0" time="300" tween="cubic" easing="in">WindowClose</animation>
    
    <controls>
        <!-- ==================================================================================== -->
        <!-- BACKGROUND LAYER -->
        <!-- ==================================================================================== -->
        
        <!-- Fullscreen Fanart -->
        <control type="image">
            <include>FullscreenDimensions</include> 
            <texture background="true" fallback="special://home/addons/plugin.video.milionar/resources/media/hub_background_v2.jpg">$INFO[Window.Property(WCS.AIPreview.Fanart)]</texture>
            <aspectratio>scale</aspectratio>
            <fadetime>600</fadetime>
        </control>
        
        <!-- Vignette / Gradient Overlay for readability -->
        <control type="image">
            <include>FullscreenDimensions</include>
            <texture colordiffuse="C0000000">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
            <!-- Simulate a gradient that is darker on left/top/bottom and lighter in center/right - simplified here with solid semi-transparent -->

            <visible>true</visible>
        </control>
        
        <!-- Dark Gradient from Bottom (for poster flow) -->
        <control type="image">
            <left>0</left>
            <top>540</top>
            <width>1920</width>
            <height>540</height>
            <texture border="2">special://home/addons/plugin.video.milionar/resources/media/gradient_bottom.png</texture> <!-- Assuming common resource, else solid color fade -->
            <colordiffuse>FF000000</colordiffuse> 
            <visible>true</visible>
        </control>

        <!-- ==================================================================================== -->
        <!-- INFO LAYER (Grouplist - stacks vertically, no gaps) -->
        <!-- ==================================================================================== -->
        <control type="group">
            <left>90</left>
            <top>60</top>
            <width>1285</width>
            <height>530</height>
            <visible>!String.IsEmpty(Window.Property(WCS.AIPreview.Title))</visible>
            <animation effect="fade" time="300">VisibleChange</animation>
            <!-- Slide animace při otevření dialogu -->
            <animation effect="slide" start="-400,0" end="0,0" time="350" delay="100" tween="cubic" easing="out">WindowOpen</animation>
            <animation effect="slide" start="0,0" end="-400,0" time="250" tween="cubic" easing="in">WindowClose</animation>
            
            <!-- Grouplist for dynamic vertical stacking -->
            <control type="grouplist">
                <left>0</left>
                <top>0</top>
                <width>1285</width>
                <height>530</height>
                <orientation>vertical</orientation>
                <itemgap>5</itemgap>
                
                <!-- Title (big font60) -->
                <control type="label">
                    <width>1285</width>
                    <height>70</height>
                    <font>font60</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Title)]</label>
                    <textcolor>white</textcolor>
                    <shadowcolor>black</shadowcolor>
                </control>
                
                <!-- Tagline (Label 35px - matches others, no gap) -->
                <!-- Collapses completely if empty property -->
                <control type="label">
                    <width>1285</width>
                    <height>35</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Tagline)]</label>
                    <textcolor>white</textcolor>
                    <visible>!String.IsEmpty(Window.Property(WCS.AIPreview.Tagline))</visible>
                </control>
                
                <!-- Metadata (Label 30px) -->
                <control type="label">
                    <width>1285</width>
                    <height>35</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Metadata)]</label>
                    <textcolor>grey</textcolor>
                </control>
                
                <!-- Extended Info (Label 30px) -->
                <!-- Collapses completely if empty property -->
                <control type="label">
                    <width>1285</width>
                    <height>35</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Extended)]</label>
                    <textcolor>white</textcolor>
                    <visible>!String.IsEmpty(Window.Property(WCS.AIPreview.Extended))</visible>
                </control>
                
                <!-- Episode Info (pouze pro seriály z Continue Watching) -->
                <control type="label">
                    <visible>!String.IsEmpty(Window.Property(WCS.AIPreview.EpisodeInfo))</visible>
                    <width>1285</width>
                    <height>35</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.EpisodeInfo)]</label>
                    <textcolor>white</textcolor>
                </control>
                
                <!-- FIXED SPACER (Always one empty line) -->
                <control type="label">
                    <width>1285</width>
                    <height>12</height>
                    <label></label>
                </control>
                
                <!-- Plot (NORMAL MODE - Full Height) -->
                <control type="textbox">
                    <visible>String.IsEmpty(Window.Property(WCS.Hub.IsActive))</visible>
                    <width>1285</width>
                    <height>285</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Plot)]</label>
                    <textcolor>white</textcolor>
                    <align>justify</align>
                    <autoscroll delay="10000" time="4000" repeat="10000">true</autoscroll>
                </control>
                
                <!-- Plot (HUB MODE - Short Height to avoid overlapping miniposters) -->
                <control type="textbox">
                    <visible>!String.IsEmpty(Window.Property(WCS.Hub.IsActive))</visible>
                    <width>1285</width>
                    <height>120</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.AIPreview.Plot)]</label>
                    <textcolor>white</textcolor>
                    <align>justify</align>
                    <autoscroll delay="10000" time="4000" repeat="10000">true</autoscroll>
                </control>
            </control>
        </control>

        <!-- ==================================================================================== -->
        <!-- HUB CONTENT LAYER - Dynamický obsah pro AI Hub karty -->
        <!-- Viditelné pouze v hub mode (WCS.Hub.IsActive) -->
        <!-- ==================================================================================== -->
        <control type="group" id="2400">
            <visible>!String.IsEmpty(Window.Property(WCS.Hub.IsActive))</visible>
            <animation effect="fade" start="0" end="100" time="300">Visible</animation>
            <animation effect="fade" start="100" end="0" time="200">Hidden</animation>
            <!-- Slide animace při otevření dialogu -->
            <animation effect="slide" start="-300,0" end="0,0" time="400" delay="150" tween="cubic" easing="out">WindowOpen</animation>
            <animation effect="slide" start="0,0" end="-300,0" time="250" tween="cubic" easing="in">WindowClose</animation>
            <!-- Posun nahoru když se zobrazí akční tlačítka -->
            <animation effect="slide" start="0,0" end="0,-70" time="300" tween="cubic" easing="out" condition="Control.HasFocus(6100) | !String.IsEmpty(Window.Property(WCS.AIPreview.ShowActions))">Conditional</animation>
            
            <left>90</left>
            <top>410</top>
            <width>1285</width>
            <height>220</height>
            

            <!-- Section Header with Badge -->
            <control type="group" id="2700">
                <left>0</left>
                <top>0</top>
                <width>1285</width>
                <height>35</height>
                <!-- Posunout nadpis dolu (spolecne s postery) pro vzdusnejsi vzhled (mezera nad nim) -->
                <animation effect="slide" start="0,0" end="0,25" time="200" tween="sine" easing="out" condition="Control.HasFocus(2500)">Conditional</animation>
                
                <!-- Section Title -->
                <control type="label">
                    <left>0</left>
                    <top>0</top>
                    <width>600</width>
                    <height>35</height>
                    <font>font13</font>
                    <label>$INFO[Window.Property(WCS.Hub.SectionTitle)]</label>
                    <textcolor>grey</textcolor>
                </control>
                
                <!-- Badge (počet položek) -->
                <control type="label">
                    <visible>!String.IsEmpty(Window.Property(WCS.Hub.Badge))</visible>
                    <left>0</left>
                    <top>0</top>
                    <width>1285</width>
                    <height>35</height>
                    <font>font12</font>
                    <label>$INFO[Window.Property(WCS.Hub.Badge)]</label>
                    <textcolor>button_focus</textcolor>
                    <align>right</align>
                </control>
            </control>
            
            <!-- Content Preview Grid - Postery uživatelských dat -->
            <control type="list" id="2500">
                <left>0</left>
                <top>40</top>
                <width>1285</width>
                <height>175</height>
                <orientation>horizontal</orientation>
                <pagecontrol>0</pagecontrol>
                <!-- Focusable and Navigable -->
                <onup>noop</onup>
                <ondown>6100</ondown>
                <visible>!String.IsEmpty(Window.Property(WCS.Hub.HasContent))</visible>
                <animation effect="fade" time="100">VisibleChange</animation>
                <!-- Posunout dolů pro vzdušnější vzhled při focusu -->
                <animation effect="slide" start="0,0" end="0,40" time="200" tween="sine" easing="out" condition="Control.HasFocus(2500)">Conditional</animation>
                
                <itemlayout height="175" width="130">
                    <control type="group">
                        <control type="image">
                            <left>5</left> <top>5</top> <width>100</width> <height>150</height>
                            <texture fallback="DefaultVideo.png" diffuse="special://home/addons/plugin.video.milionar/resources/media/card_mask.png">$INFO[ListItem.Art(poster)]</texture>
                            <aspectratio>stretch</aspectratio>
                            <!-- Dim items only when focus is active in this list -->
                            <animation effect="fade" start="100" end="40" time="200" condition="Control.HasFocus(2500)">Conditional</animation>
                        </control>
                    </control>
                </itemlayout>
                
                <focusedlayout height="175" width="130">
                    <control type="group">
                        <!-- Poster - Zoom ONLY when list has focus -->
                        <control type="image">
                            <left>5</left> <top>5</top> <width>100</width> <height>150</height>
                            <texture fallback="DefaultVideo.png" diffuse="special://home/addons/plugin.video.milionar/resources/media/card_mask.png">$INFO[ListItem.Art(poster)]</texture>
                            <aspectratio>stretch</aspectratio>
                            <animation effect="zoom" start="100" end="115" center="auto" time="150" condition="Control.HasFocus(2500)">Conditional</animation>
                        </control>
                        <!-- Focus Border - Visible ONLY when list has focus -->
                        <control type="image">
                            <left>2</left> <top>2</top> <width>106</width> <height>156</height>
                            <texture colordiffuse="FFCCCCCC">special://home/addons/plugin.video.milionar/resources/media/card_border_focus.png</texture>
                            <aspectratio>stretch</aspectratio>
                            <visible>Control.HasFocus(2500)</visible>
                            <animation effect="zoom" start="100" end="115" center="auto" time="150" condition="Control.HasFocus(2500)">Conditional</animation>
                        </control>
                    </control>
                </focusedlayout>
            </control>
            
            <!-- Empty State Hint -->
            <control type="label">
                <visible>!String.IsEmpty(Window.Property(WCS.Hub.ShowEmpty))</visible>
                <left>0</left>
                <top>200</top>
                <width>1285</width>
                <height>40</height>
                <font>font13</font>
                <label>$INFO[Window.Property(WCS.Hub.EmptyHint)]</label>
                <textcolor>grey</textcolor>
                <align>center</align>
                <animation effect="fade" time="300">VisibleChange</animation>
            </control>
        </control>

        <!-- ==================================================================================== -->
        <!-- RECOMMENDATIONS LAYER (Bottom) - "Poster Flow" -->
        <!-- ==================================================================================== -->
        
        <!-- Solid Color Strip behind cards - matches card background color #1a1e2e -->
        <control type="image">
            <left>0</left>
            <top>650</top>
            <width>1920</width>
            <height>450</height>
            <texture colordiffuse="FF1a1e2e">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
            <!-- Visible ONLY when Actions are active -->
            <visible>Control.HasFocus(6100) | !String.IsEmpty(Window.Property(WCS.AIPreview.ShowActions))</visible>
            <animation effect="fade" start="0" end="100" time="300">Visible</animation>
            <animation effect="fade" start="100" end="0" time="300">Hidden</animation>
            <!-- Slide animace spolu s kartami -->
            <animation effect="slide" start="0,450" end="0,0" time="400" delay="200" tween="cubic" easing="out">WindowOpen</animation>
            <animation effect="slide" start="0,0" end="0,450" time="300" tween="cubic" easing="in">WindowClose</animation>
        </control>

        
        <control type="list" id="2000">

            <left>30</left>
            <top>650</top>
            <width>1940</width>
            <height>450</height>
            <onup>noop</onup> <!-- Handled in Python -->
            <onleft>noop</onleft> <!-- Stop at edge, no wrap -->
            <onright>noop</onright> <!-- Stop at edge, no wrap -->
            <ondown>noop</ondown> <!-- Handled in Python -->

            <viewtype label="icon">icon</viewtype>
            <orientation>horizontal</orientation>
            <scrolltime tween="cubic" easing="out">400</scrolltime>
            <preloaditems>2</preloaditems>
            <!-- Slide animace - vyjede zdola -->
            <animation effect="slide" start="0,450" end="0,0" time="400" delay="200" tween="cubic" easing="out">WindowOpen</animation>
            <animation effect="slide" start="0,0" end="0,450" time="300" tween="cubic" easing="in">WindowClose</animation>
            
            <itemlayout height="400" width="260">
                <control type="image">
                    <left>20</left>
                    <top>35</top>
                    <width>220</width>
                    <height>330</height>
                    <texture fallback="DefaultVideo.png" diffuse="special://home/addons/plugin.video.milionar/resources/media/card_mask.png">$INFO[ListItem.Art(poster)]</texture>
                    <aspectratio>stretch</aspectratio>
                </control>
            </itemlayout>

            <focusedlayout height="400" width="260">
                <control type="image">
                    <left>20</left>
                    <top>35</top>
                    <width>220</width>
                    <height>330</height>
                    <texture fallback="DefaultVideo.png" diffuse="special://home/addons/plugin.video.milionar/resources/media/card_mask.png">$INFO[ListItem.Art(poster)]</texture>
                    <aspectratio>stretch</aspectratio>
                    <animation effect="zoom" start="100" end="125" center="auto" time="200">Focus</animation>
                </control>
                <!-- Focus Border - Millionaire Gold -->
                <control type="image">
                    <left>12</left>
                    <top>27</top>
                    <width>236</width>
                    <height>346</height>
                    <texture colordiffuse="FFCCCCCC">special://home/addons/plugin.video.milionar/resources/media/card_border_focus.png</texture>
                    <aspectratio>stretch</aspectratio>
                    <animation effect="zoom" start="100" end="125" center="auto" time="200">Focus</animation>
                </control>
            </focusedlayout>
        </control>

        <!-- Cinema Mode Dimmer (Darkens posters when actions are active) -->
        <control type="image">
            <left>0</left>
            <top>650</top>
            <width>1920</width>
            <height>450</height>
            <texture colordiffuse="D0000000">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
            <visible>Control.HasFocus(6100) | !String.IsEmpty(Window.Property(WCS.AIPreview.ShowActions))</visible>
            <animation effect="fade" start="0" end="100" time="300">Visible</animation>
            <animation effect="fade" start="100" end="0" time="300">Hidden</animation>
        </control>

        <!-- ==================================================================================== -->
        <!-- ACTION OVERLAY LAYER (Middle/Right) - Contextual Actions -->
        <!-- ==================================================================================== -->
        <control type="group" id="6000">
             <!-- Visible ONLY via Python Timer (ShowActions) OR if Buttons focused -->
             <visible>Control.HasFocus(6100) | !String.IsEmpty(Window.Property(WCS.AIPreview.ShowActions))</visible>
             <animation effect="slide" start="0,80" end="0,0" time="300" tween="cubic" easing="out">Visible</animation>
             <animation effect="slide" end="0,80" start="0,0" time="200" tween="cubic" easing="in">Hidden</animation>
             
             <!-- List of actions -->
             <control type="list" id="6100">
                <left>100</left>
                <top>575</top>
                <width>1250</width>
                <height>60</height>
                <orientation>horizontal</orientation>
                <onup>2500</onup> <!-- Up to Content Preview -->
                <ondown>noop</ondown> <!-- Down to Posters - Handled in Python to prevent Chat trigger -->
                <itemlayout height="55" width="220">
                     <!-- Default: Subtle transparent pill background -->
                     <control type="image">
                        <left>10</left>
                        <top>5</top>
                        <width>200</width>
                        <height>45</height>
                        <texture colordiffuse="25808080">special://home/addons/plugin.video.milionar/resources/media/btn_action_pill.png</texture>
                     </control>
                     <control type="label">
                        <left>10</left>
                        <top>5</top>
                        <width>200</width>
                        <height>45</height>
                        <align>center</align>
                        <aligny>center</aligny>
                        <label>$INFO[ListItem.Label]</label>
                        <textcolor>AAFFFFFF</textcolor>
                        <font>font13</font>
                     </control>
                </itemlayout>
                <focusedlayout height="55" width="220">
                     <!-- Unfocused state (list has focus but item not selected) -->
                     <control type="group">
                        <visible>!Control.HasFocus(6100)</visible>
                        <control type="image">
                           <left>10</left>
                           <top>5</top>
                           <width>200</width>
                           <height>45</height>
                           <texture colordiffuse="25808080">special://home/addons/plugin.video.milionar/resources/media/btn_action_pill.png</texture>
                        </control>
                        <control type="label">
                           <left>10</left>
                           <top>5</top>
                           <width>200</width>
                           <height>45</height>
                           <align>center</align>
                           <aligny>center</aligny>
                           <label>$INFO[ListItem.Label]</label>
                           <textcolor>AAFFFFFF</textcolor>
                           <font>font13</font>
                        </control>
                     </control>

                     <!-- Focused state: Brighter -->
                     <control type="group">
                        <visible>Control.HasFocus(6100)</visible>
                        
                        <!-- Brighter pill background -->
                        <control type="image">
                           <left>10</left>
                           <top>5</top>
                           <width>200</width>
                           <height>45</height>
                           <texture colordiffuse="60FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_action_pill.png</texture>
                        </control>
                        
                        <!-- White text -->
                        <control type="label">
                           <left>10</left>
                           <top>5</top>
                           <width>200</width>
                           <height>45</height>
                           <align>center</align>
                           <aligny>center</aligny>
                           <label>$INFO[ListItem.Label]</label>
                           <textcolor>FFFFFFFF</textcolor>
                           <font>font13</font>
                        </control>
                     </control>
                </focusedlayout>
             </control>

        </control>


        <!-- ==================================================================================== -->
        <!-- SHOWCASE POSTER (Right Side - Visible in Cinema Mode, Hidden when Chat is Visible) -->
        <!-- ==================================================================================== -->
        <control type="group">
            <visible>[Control.HasFocus(6100) | Control.HasFocus(2500) | !String.IsEmpty(Window.Property(WCS.AIPreview.ShowActions))] + !Control.IsVisible(5000)</visible>
            <animation effect="fade" start="0" end="100" time="400">Visible</animation>
            <animation effect="fade" start="100" end="0" time="300">Hidden</animation>
            
            <!-- Large Poster - 1. DEFAULT (From Hub Cards 2000) -->
            <control type="image">
                <visible>!Control.HasFocus(2500)</visible>
                <left>1430</left>
                <top>30</top>
                <width>460</width>
                <height>690</height>
                <texture fallback="DefaultVideo.png" background="true" diffuse="special://home/addons/plugin.video.milionar/resources/media/large_poster_mask.png">$INFO[Container(2000).ListItem.Art(poster)]</texture>
                <aspectratio>stretch</aspectratio>
            </control>
            
            <!-- Large Poster - 2. ITEM PREVIEW (From Miniposters 2500) -->
            <control type="image">
                <visible>Control.HasFocus(2500)</visible>
                <left>1430</left>
                <top>30</top>
                <width>460</width>
                <height>690</height>
                <texture fallback="DefaultVideo.png" background="true" diffuse="special://home/addons/plugin.video.milionar/resources/media/large_poster_mask.png">$INFO[Container(2500).ListItem.Art(poster)]</texture>
                <aspectratio>stretch</aspectratio>
                <animation effect="fade" time="200">VisibleChange</animation>
            </control>
            
            <!-- Border for Large Poster -->
            <control type="image">
                <left>1422</left>
                <top>22</top>
                <width>476</width>
                <height>706</height>
                <texture colordiffuse="FFCCCCCC">special://home/addons/plugin.video.milionar/resources/media/large_poster_border.png</texture>
                <aspectratio>stretch</aspectratio>
            </control>
        </control>

        <!-- ==================================================================================== -->
        <!-- CHAT OVERLAY LAYER (Top Right/Float) -->
        <!-- ==================================================================================== -->
        <!-- Main Chat Group - Visible only when interacting with chat or toggled -->
        <control type="group" id="5000">
            <!-- Visibility Logic: Visible if Chat items focused OR Property WCS.AIChat.Visible is true -->
            <visible>Control.HasFocus(4000) | Control.HasFocus(3000) | Control.HasFocus(3001) | !String.IsEmpty(Window.Property(WCS.AIChat.Visible))</visible>
            <animation effect="slide" start="500,0" end="0,0" time="300" tween="cubic" easing="out">Visible</animation>
            <animation effect="slide" end="500,0" start="0,0" time="300" tween="cubic" easing="in">Hidden</animation>

            <!-- Background Panel for Chat -->
            <control type="image">
                <left>1320</left> <!-- Right side panel -->
                <top>0</top>
                <width>600</width>
                <height>1080</height>
                <texture colordiffuse="F2101010">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
            </control>
            
            <control type="label">
                <left>1350</left>
                <top>40</top>
                <width>540</width>
                <height>40</height>
                <font>font30_title</font>
                <label>AI Asistent</label>
                <textcolor>button_focus</textcolor>
            </control>
            
            <!-- Thinking Indicator (Visible when AI is working) -->
            <control type="group" id="5001">
                <left>1350</left>
                <top>72</top> <!-- Adjusted to 72 as per user edit -->
                <width>540</width>
                <height>20</height>
                
                <control type="label">
                     <left>0</left>
                     <width>300</width>
                     <height>20</height>
                     <font>font12</font>
                     <label>$INFO[Window.Property(WCS.AIChat.StatusText)]</label>
                     <textcolor>grey</textcolor>
                     <align>left</align>
                </control>
                
                <control type="label">
                     <left>0</left>
                     <width>510</width> <!-- Aligned to right of textbox -->
                     <height>20</height>
                     <font>font12</font>
                     <label>$INFO[Window.Property(WCS.AIChat.Timer)]</label>
                     <textcolor>button_focus</textcolor>
                     <align>right</align>
                </control>
            </control>
            
            <!-- Chat History -->
            <control type="textbox" id="1000">
                <left>1350</left>
                <top>115</top>
                <width>510</width>
                <height>385</height> <!-- Reduced slightly to compensate for top shift -->
                <font>font13</font>
                <textcolor>white</textcolor>
                <pagecontrol>1001</pagecontrol>
                <autoscroll>false</autoscroll>
            </control>

            <!-- Focusable Transparent Button over History (Trigger Debug) -->
            <control type="button" id="1002">
                <left>1350</left>
                <top>115</top>
                <width>510</width>
                <height>385</height>
                <texturefocus border="25" colordiffuse="40FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texturefocus>
                <texturenofocus></texturenofocus>
                <onleft>2000</onleft>
                <onright>1001</onright>
                <ondown>4000</ondown>
                <onup>noop</onup>
                <visible>Control.IsVisible(5000)</visible>
            </control>

            <!-- Scrollbar -->
            <control type="scrollbar" id="1001">
                <left>1870</left>
                <top>115</top>
                <width>20</width>
                <height>400</height> <!-- Matches textbox height -->
                <onleft>1002</onleft>
                <ondown>4000</ondown>
                <texturesliderbackground border="2" colordiffuse="10FFFFFF">special://home/addons/plugin.video.milionar/resources/media/white.png</texturesliderbackground>
                <texturesliderbar border="2" colordiffuse="60FFFFFF">special://home/addons/plugin.video.milionar/resources/media/white.png</texturesliderbar>
                <texturesliderbarfocus border="2" colordiffuse="FFFFFFFF">special://home/addons/plugin.video.milionar/resources/media/white.png</texturesliderbarfocus>
                <!-- Removed nibs to avoid 'dot' artifact -->
                <textureslidernib colordiffuse="00FFFFFF"></textureslidernib>
                <textureslidernibfocus colordiffuse="00FFFFFF"></textureslidernibfocus>
                <showonepage>false</showonepage>
                <orientation>vertical</orientation>
            </control>
            
            <!-- Quick Options / Buttons -->
            <control type="list" id="4000">
                <visible>String.IsEmpty(Window.Property(WCS.AIChat.IsLoadingButtons))</visible>
                <animation effect="slide" end="-100,0" time="200" tween="back" easing="in">Hidden</animation>
                <animation effect="fade" start="100" end="0" time="200">Hidden</animation>
                <animation effect="slide" start="100,0" end="0,0" time="300" tween="cubic" easing="out">Visible</animation>
                <animation effect="fade" start="0" end="100" time="300">Visible</animation>

                <left>1350</left>
                <top>530</top> <!-- Height 400 + 30px gap -->
                <width>540</width>
                <height>450</height> <!-- Reduced slightly to fit space before input -->
                <onup>4001</onup> <!-- Safe close via hidden button -->
                <ondown>3000</ondown> <!-- Down to Input Field -->
                <onleft>2000</onleft> <!-- Left to content -->
                <itemlayout height="50" width="540">
                    <control type="label">
                        <left>10</left>
                        <label>• $INFO[ListItem.Label]</label>
                        <textcolor>grey</textcolor>
                    </control>
                </itemlayout>
                <focusedlayout height="50" width="540">
                    <control type="image">
                        <width>540</width>
                        <height>50</height>
                         <texture border="20" colordiffuse="20FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texture>
                    </control>
                     <control type="label">
                        <left>10</left>
                        <label>• $INFO[ListItem.Label]</label>
                        <textcolor>white</textcolor>
                    </control>
                </focusedlayout>
            </control>

            <!-- Hidden Button for Safe Sidebar Close (UP Action) -->
            <control type="button" id="4001">
                <left>-100</left>
                <top>-100</top>
                <width>1</width>
                <height>1</height>
                <onup>noop</onup>
                <ondown>4000</ondown>
                <onleft>2000</onleft>
                <onright>noop</onright>
            </control>
            
            <!-- Matrix Loading Group (Visible when processing buttons) -->
            <control type="group" id="5500">
                <visible>!String.IsEmpty(Window.Property(WCS.AIChat.IsLoadingButtons))</visible>
                <animation effect="zoom" start="90" end="100" center="auto" time="200">Visible</animation>
                <animation effect="fade" start="0" end="100" time="200">Visible</animation>
                <left>1350</left>
                <top>530</top>
                <width>540</width>
                <height>450</height>
                
                <!-- Glitch Text (Dissolving Button) -->
                <control type="label">
                    <left>0</left>
                    <top>150</top>
                    <width>540</width>
                    <height>50</height>
                    <font>font30_title</font>
                    <label>$INFO[Window.Property(WCS.AIChat.GlitchText)]</label>
                    <textcolor>button_focus</textcolor>
                    <align>center</align>
                    <aligny>center</aligny>
                </control>
                <!-- FUN STATUS (Center) -->
                <control type="label">
                    <left>0</left>
                    <top>210</top>
                    <width>540</width>
                    <height>30</height>
                    <font>font12</font>
                    <label>--- $INFO[Window.Property(WCS.AIChat.FunStatus)] ---</label>
                    <textcolor>grey</textcolor>
                    <align>center</align>
                </control>
                
                <!-- === SIMPLE HUD: Provider (Left) + Model (Right) === -->
                
                <!-- PROVIDER (Left - Cyan) -->
                <control type="label">
                    <left>20</left>
                    <top>15</top>
                    <width>260</width>
                    <height>25</height>
                    <font>font10</font>
                    <label>$INFO[Window.Property(WCS.AIChat.Provider)]</label>
                    <textcolor>0xFF00FFFF</textcolor>
                    <align>left</align>
                </control>
                
                <!-- MODEL (Right - Orange) -->
                <control type="label">
                    <left>280</left>
                    <top>15</top>
                    <width>250</width>
                    <height>25</height>
                    <font>font10</font>
                    <label>$INFO[Window.Property(WCS.AIChat.Model)]</label>
                    <textcolor>0xFFFFA500</textcolor>
                    <align>right</align>
                </control>
                
                <!-- Dummy Hidden Button to Trap Focus -->
                <control type="button" id="5501">
                    <left>-100</left>
                    <top>-100</top>
                    <width>1</width>
                    <height>1</height>
                    <texturefocus></texturefocus>
                    <texturenofocus></texturenofocus>
                    <onup>noop</onup>
                    <ondown>noop</ondown>
                    <onleft>noop</onleft>
                    <onright>noop</onright>
                    <onclick>noop</onclick>
                </control>
            </control>
            
            <!-- Input Field -->
            <control type="edit" id="3000">
                <left>1350</left>
                <top>1000</top>
                <width>430</width>
                <height>50</height>
                <font>font13</font>
                <ondown>noop</ondown> <!-- Handled in Python - opens debug dialog -->
                <onup>4000</onup>
                <onright>3001</onright>
                <label>Zeptej se AI...</label>
                <texturefocus border="25" colordiffuse="40FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texturefocus>
                <texturenofocus border="25" colordiffuse="20FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texturenofocus>
            </control>
            
            <!-- Send Button -->
            <control type="button" id="3001">
                <left>1790</left>
                <top>1000</top>
                <width>100</width>
                <height>50</height>
                <label>Send</label>
                <font>font12</font>
                <textcolor>FFFFFFFF</textcolor>
                <focusedcolor>FF00AAFF</focusedcolor>
                <align>center</align>
                <aligny>center</aligny>
                <texturefocus border="25" colordiffuse="60FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texturefocus>
                <texturenofocus border="25" colordiffuse="20FFFFFF">special://home/addons/plugin.video.milionar/resources/media/btn_rounded.png</texturenofocus>
                <onleft>3000</onleft>
                <ondown>4000</ondown>
            </control>
        </control>
        
        <!-- Subtle Hint to open chat if hidden -->
        <control type="group">
            <visible>![Control.HasFocus(4000) | Control.HasFocus(3000) | Control.HasFocus(3001) | !String.IsEmpty(Window.Property(WCS.AIChat.Visible))]</visible>
            <left>1850</left>
            <top>500</top>
            <control type="image">
                 <width>50</width>
                 <height>100</height>
                 <texture flipx="true">common/arrow_right.png</texture> <!-- Or chat icon -->
                 <colordiffuse>80FFFFFF</colordiffuse>
            </control>
        </control>

        <!-- ==================================================================================== -->
        <!-- NAVIGATION SIDEBAR (Left Side) -->
        <!-- ==================================================================================== -->
        <!-- ==================================================================================== -->
        <!-- NAVIGATION SIDEBAR (Left Side) -->
        <!-- ==================================================================================== -->
        <control type="group" id="7000">
            <visible>Control.HasFocus(7100) | Control.HasFocus(7200) | !String.IsEmpty(Window.Property(WCS.NavSidebar.Visible))</visible>
            <animation effect="slide" start="-450,0" end="0,0" time="300" tween="cubic" easing="out" condition="String.IsEmpty(Window.Property(WCS.NavSidebar.NoAnimation))">Visible</animation>
            <animation effect="slide" end="-450,0" start="0,0" time="300" tween="cubic" easing="in" condition="String.IsEmpty(Window.Property(WCS.NavSidebar.NoAnimation))">Hidden</animation>
            
            <!-- Background Panel -->
            <control type="image">
                <left>0</left>
                <top>0</top>
                <width>450</width>
                <height>1080</height>
                <texture colordiffuse="F2101010">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
            </control>
            
            <!-- Gradient Edge (Right side of sidebar) -->
            <control type="image">
                <left>440</left>
                <top>0</top>
                <width>30</width>
                <height>1080</height>
                <texture colordiffuse="80000000">special://home/addons/plugin.video.milionar/resources/media/gradient_right.png</texture>
            </control>
            
            <!-- Header Title -->
            <control type="group">
                <left>0</left><top>0</top><width>450</width><height>150</height>
                <control type="image">
                    <left>0</left><top>0</top><width>450</width><height>150</height>
                    <texture colordiffuse="FF101010">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
                </control>
                <control type="image">
                    <left>69</left><top>39</top><width>72</width><height>72</height>
                    <aspectratio>keep</aspectratio>
                    <texture colordiffuse="$INFO[Window(Home).Property(milionar.logo.tint)]">special://home/addons/plugin.video.milionar/resources/media/brand/milionar-mark.png</texture>
                </control>
                <control type="label">
                    <left>153</left><top>31</top><width>228</width><height>88</height>
                    <font>font32_milionar_brand</font><aligny>center</aligny>
                    <textcolor>$INFO[Window(Home).Property(milionar.logo.wordmark)]</textcolor>
                    <label>MILIONÁŘ</label>
                    <visible>Skin.HasSetting(MilionarDefaultsV1)</visible>
                </control>
                <control type="label">
                    <left>153</left><top>31</top><width>228</width><height>88</height>
                    <font>font32_title</font><aligny>center</aligny>
                    <textcolor>$INFO[Window(Home).Property(milionar.logo.wordmark)]</textcolor>
                    <label>MILIONÁŘ</label>
                    <visible>!Skin.HasSetting(MilionarDefaultsV1)</visible>
                </control>
            </control>

            <!-- Horizontal Icon Bar -->
            <control type="list" id="7200">
                <left>30</left>
                <top>155</top>
                <width>390</width>
                <height>90</height>
                <onleft>noop</onleft>
                <onright>2000</onright>
                <onup>noop</onup>
                <ondown>7100</ondown>
                <orientation>horizontal</orientation>
                
                <itemlayout width="130" height="90">
                    <control type="image">
                        <left>30</left>
                        <top>10</top>
                        <width>70</width>
                        <height>70</height>
                        <texture>$INFO[ListItem.Icon]</texture>
                        <colordiffuse>grey</colordiffuse>
                        <aspectratio>keep</aspectratio>
                    </control>
                </itemlayout>
                
                <focusedlayout width="130" height="90">
                    <control type="image">
                        <left>15</left>
                        <top>5</top>
                        <width>100</width>
                        <height>80</height>
                        <texture colordiffuse="FF0090EA">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
                        <visible>Control.HasFocus(7200)</visible>
                    </control>
                    <control type="image">
                        <left>30</left>
                        <top>10</top>
                        <width>70</width>
                        <height>70</height>
                        <texture>$INFO[ListItem.Icon]</texture>
                        <colordiffuse>white</colordiffuse>
                        <aspectratio>keep</aspectratio>
                        <visible>Control.HasFocus(7200)</visible>
                    </control>
                    <control type="image">
                        <left>30</left>
                        <top>10</top>
                        <width>70</width>
                        <height>70</height>
                        <texture>$INFO[ListItem.Icon]</texture>
                        <colordiffuse>grey</colordiffuse>
                        <aspectratio>keep</aspectratio>
                        <visible>!Control.HasFocus(7200)</visible>
                    </control>
                </focusedlayout>
            </control>
            
            <!-- Navigation Menu List -->
            <control type="list" id="7100">
                <left>0</left>
                <top>250</top>
                <width>450</width>
                <height>830</height>
                <onright>2000</onright>
                <onleft>noop</onleft>
                <onup>7200</onup>
                <orientation>vertical</orientation>
                <scrolltime tween="cubic" easing="out">200</scrolltime>
                
                <itemlayout height="100" width="450">
                    <control type="group">
                        <control type="image">
                            <left>30</left>
                            <top>15</top>
                            <width>70</width>
                            <height>70</height>
                            <texture>$INFO[ListItem.Icon]</texture>
                            <aspectratio>keep</aspectratio>
                            <colordiffuse>grey</colordiffuse>
                        </control>
                        <control type="label">
                            <left>120</left>
                            <top>0</top>
                            <width>310</width>
                            <height>100</height>
                            <font>font30</font>
                            <label>$INFO[ListItem.Label]</label>
                            <textcolor>white</textcolor>
                            <aligny>center</aligny>
                        </control>
                    </control>
                </itemlayout>
                
                <focusedlayout height="100" width="450">
                    <control type="group">
                        <control type="image">
                            <left>0</left>
                            <top>0</top>
                            <width>450</width>
                            <height>100</height>
                            <texture colordiffuse="FF0090EA">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
                            <visible>Control.HasFocus(7100)</visible>
                        </control>
                        <control type="image">
                            <left>0</left>
                            <top>0</top>
                            <width>5</width>
                            <height>100</height>
                            <texture colordiffuse="FFFFFFFF">special://home/addons/plugin.video.milionar/resources/media/white.png</texture>
                            <visible>Control.HasFocus(7100)</visible>
                        </control>
                        <control type="image">
                            <left>30</left>
                            <top>15</top>
                            <width>70</width>
                            <height>70</height>
                            <texture>$INFO[ListItem.Icon]</texture>
                            <aspectratio>keep</aspectratio>
                            <colordiffuse>white</colordiffuse>
                            <visible>Control.HasFocus(7100)</visible>
                        </control>
                        <control type="image">
                            <left>30</left>
                            <top>15</top>
                            <width>70</width>
                            <height>70</height>
                            <texture>$INFO[ListItem.Icon]</texture>
                            <aspectratio>keep</aspectratio>
                            <colordiffuse>grey</colordiffuse>
                            <visible>!Control.HasFocus(7100)</visible>
                        </control>
                        <control type="label">
                            <left>120</left>
                            <top>0</top>
                            <width>310</width>
                            <height>100</height>
                            <font>font30</font>
                            <label>$INFO[ListItem.Label]</label>
                            <textcolor>white</textcolor>
                            <shadowcolor>black</shadowcolor>
                            <aligny>center</aligny>
                            <visible>Control.HasFocus(7100)</visible>
                        </control>
                        <control type="label">
                            <left>120</left>
                            <top>0</top>
                            <width>310</width>
                            <height>100</height>
                            <font>font30</font>
                            <label>$INFO[ListItem.Label]</label>
                            <textcolor>grey</textcolor>
                            <aligny>center</aligny>
                            <visible>!Control.HasFocus(7100)</visible>
                        </control>
                    </control>
                </focusedlayout>
            </control>
        </control>
        
        <!-- Subtle Hint to open nav sidebar if hidden (Left Edge) -->
        <control type="group">
            <visible>String.IsEmpty(Window.Property(WCS.NavSidebar.Visible)) + !Control.HasFocus(7100)</visible>
            <left>0</left>
            <top>500</top>
            <control type="image">
                 <width>50</width>
                 <height>100</height>
                 <texture>common/arrow_right.png</texture>
                 <colordiffuse>40FFFFFF</colordiffuse>
            </control>
        </control>

    </controls>
</window>
