<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <requires lib="gtk" version="4.0"/>
  <requires lib="Adw" version="1.0"/>

  <template class="RosterWindow" parent="AdwApplicationWindow">
    <property name="default-width">1200</property>
    <property name="default-height">800</property>
    <property name="content">
      <object class="AdwToastOverlay" id="toast_overlay">
        <property name="child">
          <object class="GtkPaned" id="main_pane">
        <property name="orientation">horizontal</property>
        <property name="position">180</property>
        <property name="shrink-start-child">False</property>
        <property name="resize-start-child">True</property>
        <property name="shrink-end-child">False</property>
        <property name="resize-end-child">True</property>
        <property name="wide-handle">False</property>

        <!-- LEFT: Sidebar Panel with AdwToolbarView -->
        <property name="start-child">
          <object class="AdwToolbarView">
            <property name="width-request">200</property>

            <!-- Sidebar Header Bar -->
            <child type="top">
              <object class="AdwHeaderBar">
                <property name="show-title">False</property>
                <property name="show-end-title-buttons">False</property>
                <property name="show-start-title-buttons">False</property>
                <child type="start">
                  <object class="GtkLabel">
                    <property name="label">Projects</property>
                    <property name="margin-start">6</property>
                    <style>
                      <class name="title"/>
                    </style>
                  </object>
                </child>
                <child type="end">
                  <object class="GtkButton" id="add_project_button">
                    <property name="icon-name">list-add-symbolic</property>
                    <property name="tooltip-text">Add Project</property>
                    <signal name="clicked" handler="on_add_project_clicked"/>
                    <style>
                      <class name="flat"/>
                    </style>
                  </object>
                </child>
              </object>
            </child>

            <!-- Sidebar Content -->
            <property name="content">
              <object class="GtkBox">
                <property name="orientation">vertical</property>

                <!-- Projects List -->
                <child>
                  <object class="GtkScrolledWindow">
                    <property name="vexpand">True</property>
                    <child>
                      <object class="GtkListBox" id="projects_listbox">
                        <style>
                          <class name="navigation-sidebar"/>
                        </style>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </property>
          </object>
        </property>

        <!-- RIGHT: Main Content Panel with AdwToolbarView -->
        <property name="end-child">
          <object class="AdwToolbarView">

            <!-- Main Header Bar -->
            <child type="top">
              <object class="AdwHeaderBar">
                <property name="show-title">False</property>
                <property name="show-start-title-buttons">False</property>
                <property name="show-end-title-buttons">False</property>

                <!-- Left side buttons -->
                <child type="start">
                  <object class="GtkButton" id="save_request_button">
                    <property name="icon-name">document-save-symbolic</property>
                    <property name="tooltip-text">Save Current Request (Ctrl+S)</property>
                    <signal name="clicked" handler="on_save_request_clicked"/>
                    <style>
                      <class name="flat"/>
                    </style>
                  </object>
                </child>

                <child type="start">
                  <object class="GtkButton" id="export_request_button">
                    <property name="icon-name">export-symbolic</property>
                    <property name="tooltip-text">Export as cURL</property>
                    <signal name="clicked" handler="on_export_request_clicked"/>
                    <style>
                      <class name="flat"/>
                    </style>
                  </object>
                </child>

                <!-- Right side buttons -->
                <child type="end">
                  <object class="GtkBox">
                    <property name="spacing">6</property>

                    <!-- New Request Button -->
                    <child>
                      <object class="GtkButton" id="new_request_button">
                        <property name="icon-name">list-add-symbolic</property>
                        <property name="tooltip-text">New Request (Ctrl+T)</property>
                        <style>
                          <class name="flat"/>
                        </style>
                      </object>
                    </child>

                    <!-- Main Menu -->
                    <child>
                      <object class="GtkMenuButton">
                        <property name="primary">True</property>
                        <property name="icon-name">open-menu-symbolic</property>
                        <property name="tooltip-text" translatable="yes">Main Menu</property>
                        <property name="menu-model">primary_menu</property>
                      </object>
                    </child>

                    <!-- Window Controls -->
                    <child>
                      <object class="GtkWindowControls">
                        <property name="side">end</property>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>

            <!-- Tab Bar as separate top bar -->
            <child type="top">
              <object class="AdwTabBar" id="tab_bar">
                <property name="view">tab_view</property>
                <property name="autohide">False</property>
                <property name="expand-tabs">False</property>
              </object>
            </child>

            <!-- Main Content: Vertical Paned with Tab View and History Panel -->
            <property name="content">
              <object class="GtkPaned">
                <property name="orientation">vertical</property>
                <property name="position">600</property>
                <property name="shrink-start-child">False</property>
                <!-- Don't allow history panel to shrink below its minimum size -->
                <property name="shrink-end-child">False</property>
                <property name="resize-start-child">True</property>
                <property name="resize-end-child">True</property>

                <!-- AdwTabView as main content area -->
                <property name="start-child">
                  <object class="AdwTabView" id="tab_view">
                    <property name="vexpand">True</property>
                  </object>
                </property>

                <!-- History Panel -->
                <property name="end-child">
                  <object class="GtkBox">
                    <property name="orientation">vertical</property>
                    <!-- Set minimum height to ensure header is always visible -->
                    <property name="height-request">50</property>

                    <!-- History Header -->
                    <child>
                      <object class="GtkBox">
                        <property name="orientation">horizontal</property>
                        <property name="spacing">12</property>
                        <property name="margin-start">12</property>
                        <property name="margin-end">12</property>
                        <property name="margin-top">6</property>

                        <child>
                          <object class="GtkLabel">
                            <property name="label">Request History</property>
                            <property name="hexpand">True</property>
                            <property name="xalign">0</property>
                            <style>
                              <class name="heading"/>
                            </style>
                          </object>
                        </child>
                      </object>
                    </child>

                    <!-- History List -->
                    <child>
                      <object class="GtkScrolledWindow">
                        <property name="vexpand">True</property>
                        <property name="min-content-height">50</property>

                        <child>
                          <object class="GtkListBox" id="history_listbox">
                            <style>
                              <class name="boxed-list"/>
                            </style>
                          </object>
                        </child>
                      </object>
                    </child>
                  </object>
                </property>
              </object>
            </property>
          </object>
        </property>
      </object>
        </property>
      </object>
    </property>
  </template>

  <menu id="primary_menu">
    <section>
      <item>
        <attribute name="label" translatable="yes">_Preferences</attribute>
        <attribute name="action">app.preferences</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
        <attribute name="action">app.shortcuts</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">_About Roster</attribute>
        <attribute name="action">app.about</attribute>
      </item>
    </section>
  </menu>
</interface>
