/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
/* Styles for both vertical and horizontal tabs */
@import url('chrome://browser/content/zen-styles/zen-tabs/vertical-tabs.css');

#zen-tabbox-wrapper {
  position: relative;
  z-index: 0;
}

@media -moz-pref('zen.workspaces.hide-default-container-indicator') {
  .tabbrowser-tab[zenDefaultUserContextId='true'] .tab-context-line {
    display: none !important;
  }
}

/* ==========================================================================
   Single Toolbar Mode - Top Bar Handling (Includes External CSS)
   ========================================================================== */
:root[zen-single-toolbar='true']:not([customizing]) {
  #zen-appcontent-navbar-wrapper {
    display: flex;
    -moz-window-dragging: drag; /* Allow dragging the window via this bar */
    min-height: var(--zen-element-separation);
    height: var(--zen-element-separation);

    /* Ensure Personal Toolbar takes available width */
    & #PersonalToolbar {
      width: -moz-available;
    }

    /* Include styles for the top bar under certain conditions:
      * - Bookmarks toolbar is visible OR
      * - The container is explicitly marked to hide controls (e.g., on Linux with reversed controls)
      */
    &:has(#PersonalToolbar[collapsed='false']) {
%include zen-tabs/vertical-tabs-topbar.inc.css
    }
    &[should-hide='true'] {
%include zen-tabs/vertical-tabs-topbar.inc.css
    }

    /* Hide the top bar completely in fullscreen mode */
    :root[inDOMFullscreen='true'] & {
      max-height: 0 !important;
      min-height: unset !important;
      opacity: 0 !important;
      pointer-events: none !important;
    }
  }
}


/* ==========================================================================
  Very Special Occasions - Complex Layout Fixes
  ========================================================================== */

/* Exclude these complex fixes if in compact mode */
:root:not([zen-compact-mode='true']) {

  /* --- Fix: Right Sidebar + Collapsed + Standard Window Buttons --- */
  &[zen-right-side='true']:not([zen-sidebar-expanded='true']):not([zen-window-buttons-reversed='true']) {
    /* Push toolbox down below the top toolbar */
    & #navigator-toolbox {
      margin-top: var(--zen-toolbar-height) !important;
    }
    /* Pull window buttons container leftwards over the collapsed sidebar */
    & .titlebar-buttonbox-container {
      margin-right: calc(-1 * var(--zen-toolbox-max-width)) !important;
    }
    /* Allow overflow for the button box */
    & #zen-appcontent-wrapper {
      overflow-x: visible;
    }
    /* Reset padding for top buttons */
    & #zen-sidebar-top-buttons-customization-target {
      padding-top: 0;
    }
    /* Include common fixes for this top-button scenario */
%include zen-tabs/vertical-tabs-topbuttons-fix.css
  }

  /* --- Fix: Left Sidebar + Collapsed + Reversed Window Buttons --- */
  &:not([zen-right-side='true']):not([zen-sidebar-expanded='true'])[zen-window-buttons-reversed='true'] {
    /* Push toolbox down below the top toolbar */
    & #navigator-toolbox {
      margin-top: var(--zen-toolbar-height) !important;
    }
    /* Pull window buttons container rightwards over the collapsed sidebar */
    & .titlebar-buttonbox-container {
      margin-left: calc(-1 * var(--zen-toolbox-max-width) + var(--zen-toolbox-padding)) !important;
    }
    /* Allow overflow for the button box */
    & #zen-appcontent-wrapper {
      overflow-x: visible;
    }
    /* Reset padding for top buttons */
    & #zen-sidebar-top-buttons-customization-target {
      padding-top: 0;
    }
    /* Add padding to the right of the nav container */
    & #zen-appcontent-navbar-container {
      padding-right: var(--zen-element-separation);
    }
    /* Include common fixes for this top-button scenario */
%include zen-tabs/vertical-tabs-topbuttons-fix.css
  }
}