/* Border Variables */
$border-style: round;
$border-blurred: $primary-background-lighten-3;
$border-blurred-light: $primary-background;
$border: $primary-lighten-3;
$border-disabled: $panel;

/* Layout Dimensions */
$pinned_sidebar_width: 17;
$file_list_width: 1fr;
$preview_sidebar_width: 35vw;
$footer_unfocus_height: 8;
$footer_focus_height: 10;

/* Scrollbar Colors */
$scrollbar: $primary;
$scrollbar-hover: $primary-lighten-3;
$scrollbar-active: $primary-lighten-3;
$scrollbar-background: $primary-muted;
$scrollbar-background-hover: $primary-muted;
$scrollbar-background-active: $primary-muted;
$scrollbar-corner-color: $primary-muted;


* {
  scrollbar-size: 1 1;
  &:ansi {
    scrollbar-background-hover: $scrollbar-background;
    scrollbar-background-active: $scrollbar-background;
  }
}

/* Compact mode */
.compact {
  #menu { display: none; }
  #below_menu { border: none; }
  #pinned_sidebar_container { width: 16; }
  #preview_sidebar { width: 25vw; }
  #footer {
    height: 7;
    &:focus-within {
      height: 7;
    }
  }
}

/* border styling for main widgets */
#menu,
#below_menu,
#pinned_sidebar_container,
#file_list_container,
#preview_sidebar,
#path_switcher,
#zoxide_options,
#file_search_options,
#below_menu Button,
#footer > *,
FileListRightClickOptionList {
  background: transparent;
  border: $border-style $border-blurred;
  border-subtitle-color: $background;
  border-subtitle-background: $border-blurred;
  opacity: 1 !important;
  background-tint: transparent !important;
  text-opacity: 1 !important;
  tint: transparent !important;
  &:disabled {
    border: $border-style $border-disabled;
  }
  &:ansi {
    border-subtitle-background: transparent;
    border-subtitle-color: $border-blurred;
    &:light {
      border-subtitle-background: transparent;
      border-subtitle-color: $border-blurred-light;
    }
  }
  &:light {
    border: $border-style $border-blurred-light;
    border-subtitle-background: $border-blurred-light;
  }
}

#menu:focus-within,
#below_menu:focus-within,
#pinned_sidebar_container:focus-within,
#file_list_container:focus-within,
#preview_sidebar:focus-within,
#preview_sidebar:focus,
#path_switcher:focus-within,
#zoxide_options,
#file_search_options,
#below_menu Button:focus,
#below_menu Button:hover,
#file_list.-maximized,
#pinned_sidebar.-maximized,
#preview_sidebar .inner_preview.-maximized,
#footer > *:focus,
FileListRightClickOptionList {
  border: $border-style $border;
  border-subtitle-background: $border;
  &:ansi {
    border-subtitle-background: transparent;
    border-subtitle-color: $border;
    &:light {
      border-subtitle-background: transparent;
      border-subtitle-color: $border;
    }
  }
  &:light {
    border-subtitle-background: $border;
    border-subtitle-color: $background;
  }
}

.hide,
.hidden { display: none }

Input, TextArea {
  .input--placeholder,
  .text-area--placeholder { color: $foreground-darken-1 }
  .text-area--cursor-gutter {
      color: $foreground;
      background: $boost;
      text-style: bold;
  }
  &:ansi {
    .input--cursor,
    .text-area--selection { color: $primary }
    .input--selection,
    .text-area--selection {
      background: $secondary-darken-3;
      text-style: bold;
    }
    .text-area--cursor-line,
    .text-area--cursor-gutter { background: transparent }
  }
}

Toast {
  max-height: 100%;
  width: 33vw;
  .toast--title {
    text-style: underline;
  }
  &.-information { border-right: outer $success }
  &.-warning { border-right: outer $warning }
  &.-error { border-right: outer $error }
  &:ansi {
    padding: 0;
    background: transparent;
    padding-left: 1;
    &.-information { border: $border-style $success }
    &.-warning { border: $border-style $warning }
    &.-error { border: $border-style $error }
  }
}

OptionList {
  text-wrap: nowrap;
  text-overflow: ellipsis;
}

Bar { width: 1fr }

Tooltip {
  background: $background-lighten-1;
  &:light {
    background: $background-darken-1;
    color: black;
  }
  &:ansi {
    background: transparent;
    border: $border-style $border-blurred;
  }
  &:light:ansi { border: $border-style $border-blurred-light }
}

#headerArea {
  padding: 0 1 0 1;
  #newTabRight {
    width: 1fr;
    Button {
      max-width: 3;
      background: transparent;
      color: $foreground;
      &.-primary.-active {
        color: $foreground;
        background: $background
      }
      &.-active {
        background: $background;
        color: $foreground
      }
    }
  }
  Tabline {
    TablineTab {
      color: auto;
      opacity: 1 !important;
      background-tint: transparent !important;
      text-opacity: 1 !important;
      tint: transparent !important;
      &:hover {
        background: $boost-lighten-3;
        color: $foreground;
        &:ansi { background: transparent }
      }
      &.-active {
        background: $primary;
        color: $background;
        &:hover {
          background: $primary;
          color: $background;
        }
      }
    }
    .underline--bar {
      color: $primary;
      background: $background-lighten-3;
    }
    Underline:ansi {
      text-style: none !important;
    }
    /* color may be inaccurate due to terminals *\
    \* you need to change the underline bar and */
    &:ansi .underline--bar { background: $background-lighten-3 }
    &:light .underline--bar { background: $background-darken-1 }
    &:ansi:light .underline--bar { background: $background-darken-3 }
  }

  &:focus-within > HeaderClock,
  &:focus-within > #newTabRight {
    border-bottom: solid $foreground-darken-3;
    &:ansi { border-bottom: solid $foreground-darken-3 }
    &:light { border-bottom: solid $foreground-lighten-3 }
    &:ansi:light { border-bottom: solid $foreground-lighten-3 }
  }

  &:focus-within > Tabline .underline--bar { background: $foreground-darken-3 }

  HeaderClock, #newTabRight {
    background: transparent;
    dock: none;
    opacity: 1 !important;
    background-tint: transparent !important;
    text-opacity: 1 !important;
    tint: transparent !important;
    /* border bottom colors, sometimes it can be  *\
    |* too thin, so switch to heavy and not solid *|
    \* use lighten-1 instead of lighten-3         */
    border-bottom: solid $background-lighten-3;
    &:ansi { border-bottom: solid $background-lighten-3 }
    &:light { border-bottom: solid $background-darken-1 }
    &:ansi:light { border-bottom: solid $background-darken-3 }
  }
}

#menu {
  align: left middle;
  height: 3;
  margin: 0 1 0 1;
  padding: 0 1;
  scrollbar-size: 0 0;
  Button {
    &:ansi { background: transparent }
    &:disabled {
      opacity: 1 !important;
      background-tint: transparent !important;
      text-opacity: 1 !important;
      color: $panel-lighten-3;
      tint: transparent !important;
    }
    &:light:disabled { color: $panel-darken-3 }
    &:ansi:hover { color: $primary }
    &:light:ansi:hover { color: $secondary }
  }
}

#below_menu {
  margin: 0 1 0 1;
  max-height: 11;
  Input {
    height: 3;
    width: 1fr;
    margin: 0 1 0 1;
    padding: 0 1 0 1;
    overflow: hidden hidden;
    color: $foreground;
  }
  Input.hide_border_bottom {
    border: $border-style $accent !important;
    border-bottom: none !important;
    height: 3;
  }
  Button {
    margin: 0 1;
    height: 3;
    max-width: 7;
  }
  PathAutoCompleteInput {
    padding: 0 1 0 1;
    margin: -1 1 0 25;
    overlay: screen;
    width: 1fr;
    border: $border-style $accent;
    border-top: none;
    background: $background;
    &:ansi { background: transparent }
    AutoCompleteList {
      width: 1fr;
      max-height: 4;
      scrollbar-color: $accent;
      scrollbar-background: $accent-muted;
      scrollbar-color-hover: $accent-lighten-3;
      scrollbar-color-active: $accent-lighten-3;
      scrollbar-background-hover: $accent-muted;
      scrollbar-background-active: $accent-muted;
      .option-list--option-highlighted {
        color: $block-cursor-foreground;
        background: $accent;
      }
    }
    Option { width: 100% }
  }
}

.option {
  border: none;
  height: 1;
  max-width: 3;
  width: 3;
  padding: 0;
  margin: 0 1 0 0;
}

#main {
  padding: 0 0;
  height: 1fr;
  align: center middle;
  /* I legit have no clue why there is a random right padding and i cant get rid of it, so compensation with a left padding */
  margin: 0 0 0 1;
}

#file_list_container {
  height: 1fr;
  width: $file_list_width;
}

#file_list, #file_list_visual { height: 1fr }

#pinned_sidebar_container,
#file_list_container,
#keybinds_group {
  Input {
    padding: 0 0 0 1;
    margin: 0;
    height: 1;
    border: none;
    background: transparent;
    color: $foreground-lighten-1;
  }
  OptionList {
    background: transparent;
    border: none;
    margin: 0 0;
  }
}

#pinned_sidebar_container {
  height: 1fr;
  margin: 0;
  width: $pinned_sidebar_width;
  scrollbar-size: 0 0 !important;
  & > PinnedSidebar { scrollbar-size: 0 0 !important }
  & > Input { display: none }
  &:focus-within > Input,
  Input.show,
  & > Input:hover,
  &:hover > Input { display: block }
}

#pinned_sidebar { height: 1fr }
#pinned_sidebar { padding: 0 }

#preview_sidebar {
  height: 1fr;
  margin: 0;
  width: $preview_sidebar_width;
  layout: horizontal;
  padding: 0 1;
  overflow: auto auto;
  scrollbar-size: 1 1;
  & > Static {
    text-overflow: clip;
    text-wrap: nowrap;
    width: auto;
  }
 /* scrollbars are useless, reminder */
  &.clip { scrollbar-size: 0 0 }
  &.clip > Static {
    width: 1fr;
    overflow-x: hidden !important;
  }
  & > * {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    &TextArea {
      padding: 0 1;
    }
  }
  & > FileList { height: 1fr }
}

#preview_sidebar { padding: 0 }

#image_preview {
  width: auto;
  height: auto;
  align: center bottom;
}

#footer {
  height: $footer_unfocus_height;
  margin: 0 1;

  & > * {
    height: 1fr;
    background: transparent;
  }

  &:focus-within {
    height: $footer_focus_height;
    max-height: 40vh;
  }
}

#processes { padding: 0 0 0 1 }

#metadata {
  layout: horizontal;
  padding-left: 1;
  padding-right: 0;
  scrollbar-gutter: stable;
  & > VerticalGroup > Static {
    text-wrap: nowrap;
    text-overflow: ellipsis;
  }
  #metadata-keys { margin-right: 1 }
}

ProcessContainer {
  scrollbar-gutter: stable;
  margin: 0
}

ProgressBarContainer {
  padding-right: 1;
  HorizontalGroup {
    height: 1;
    & > #icon { margin-right: 1 }
  }
  ProgressBar { width: 1fr }
  &.error .bar--bar,
  &.error .bar--complete { color: $error }
  &.done .bar--complete { color: $success }
  .bar--indeterminate { color: $accent }
  .bar--bar { color: $warning }
}

Content.selected { color: red }
FileList, PinnedSidebar, Clipboard, CommandList, #zoxide_options, FileListRightClickOptionList, #file_search_options {
  padding: 0 0 0 0;
  .option-list--option-disabled { color: $border-blurred }
  &:light .option-list--option-disabled { color: $border-blurred-light }
  .option-list--option-highlighted {
    color: $foreground;
    background: transparent;
  }
  .option-list--option-hover {
    color: $primary;
    background: transparent
  }
  &:focus .option-list--option-highlighted,
  &.-popup-shown .option-list--option-highlighted {
    color: $block-cursor-foreground;
    background: $primary;
  }
  &:blur .selection-list--button-selected-highlighted,
  &:blur .selection-list--button-highlighted {
    background: transparent;
    color: $primary
  }
  .selection-list--button {
    background: transparent;
    color: $primary;
  }
  .selection-list--button-selected {
    background: transparent;
    color: $primary;
  }
  .selection-list--button-highlighted,
  &.-popup-shown .selection-list--button-highlighted {
    background: $primary;
    color: $background;
  }
  .selection-list--button-selected-highlighted,
  &.-popup-shown .selection-list--button-selected-highlighted {
    background: $primary;
    color: $background;
  }
}
FileList .option-list--option-highlighted {
  color: $block-cursor-background;
  background: transparent;
  text-style: bold;
}

#dialog {
  max-width: 57;
  max-height: 15;
  height: 75vh;
  width: 75vw;
  overflow-y: auto;
  border-title-align: center;
  border-subtitle-align: center;
  Label { min-height: 1 }
}

ModalScreen Button:ansi {
  background: transparent;
  border: $border-style $surface-darken-1;
  &.-active {
    border: $border-style $surface-lighten-1;
    tint: transparent;
    color: auto;
    text-style: none;
  }
  &.-primary {
    border: $border-style $primary-lighten-3;
    color: white;
    &:hover { border: $border-style $primary }
    &.-active { border: $border-style $primary-darken-3 }
  }
  &.-success {
    border: $border-style $success-lighten-2;
    color: white;
    &:hover { border: $border-style $success }
    &.-active { border: $border-style $success-darken-2 }
  }
  &.-warning{
    border: $border-style $warning-lighten-2;
    color: white;
    &:hover { border: $border-style $warning }
    &.-active { border: $border-style $warning-darken-2 }
  }
  &.-error {
    border: $border-style $error-lighten-2;
    color: white;
    &:hover { border: $border-style $error }
    &.-active { border: $border-style $error-darken-2 }
  }
}

ZDToDirectory, FileSearch {
  align: center middle;
  Input {
    width: 100%;
    max-width: 100%;
    padding: 0 1;
    background: transparent;
    border: $border-style $border;
  }
  OptionList {
    width: 100%;
    max-width: 100%;
    height: 1fr;
    background: transparent;
    border: $border-style $border;
    padding: 0;
    .option-list--option-highlighted {
      background: $primary !important;
      color: $background !important;
    }
    &.empty {
      border: $border-style $error !important;
      border-subtitle-background: $error !important;
    }
  }
  & > VerticalGroup {
    max-width: 50vw;
    max-height: 50vh;
  }
}

Keybinds {
  align: center middle;
  #keybinds_data {
    width: 100%;
    max-width: 100%;
    height: 1fr;
    background: transparent;
    padding: 0;
    .option-list--option-highlighted {
      background: $primary;
      color: $background;
    }
  }
  #keybinds_group {
    max-width: 60vw;
    max-height: 80vh;
    border: $border-style $border;
  }
}

Dismissable {
  align: center middle;
  #dialog {
    grid-size: 1;
    grid-gutter: 1 2;
    grid-rows: 1fr 3; /* take up all the space available */
    padding: 1 3;
    border: $border-style $border;
    column-span: 3;
  }
  #message {
    height: 1fr;
    width: 1fr;
    content-align: center middle;
    text-align: center
  }
  Container { align: center middle }
  Button { width: 50% }
}

YesOrNo {
  align: center middle;
  #dialog {
    grid-size: 2;
    grid-gutter: 1 2;
    padding: 1 3 1 3;
    border: $border-style $border;
    grid-rows: 1fr 3; /* enough space for 1fr */
    &.with_toggle {
      grid-rows: 2 3 1; /* not enough space for two lines at times */
      padding: 1 3 0 3;
    }
    #question_container {
      column-span: 2;
      height: 1fr;
      width: 1fr;
      content-align: center middle;
      .question {
        content-align: center middle;
        width: 1fr;
        height: 1fr;
        text-align: center;
      }
    }
    Button { width: 100% }
    #dontAskAgain {
      column-span: 2;
      content-align: center middle;
      align: center middle;
      Switch {
        border: none;
        padding: 0;
        background: transparent;
        margin: 0 2 0 0;
        &:focus {
          border: none;
          & > .switch--slider { color: $panel-lighten-1 }
          &.-on > .switch--slider { color: $success-lighten-1 }
        }
      }
    }
  }
}

CommonFileNameDoWhat {
  align: center middle;
  #dialog {
    grid-size: 2;
    grid-gutter: 1 2;
    grid-rows: 2 3 3 1; /* need the two lines for label */
    padding: 1 3 0 3;
    border: $border-style $border;
    #question_container {
      column-span: 2;
      height: 1fr;
      width: 1fr;
      content-align: center middle;
      .question {
        content-align: center middle;
        width: 1fr;
        height: 1fr;
        text-align: center;
      }
    }
    Button { width: 100% }
    #dontAskAgain {
      column-span: 2;
      content-align: center middle;
      align: center middle;
      Switch {
        border: none;
        padding: 0;
        background: transparent;
        margin: 0 2 0 0;
        &:focus {
          border: none;
          & > .switch--slider { color: $panel-lighten-1 }
          &.-on > .switch--slider { color: $success-lighten-1 }
        }
      }
    }
  }
}

GiveMePermission {
  align: center middle;
  #dialog {
    grid-size: 2;
    grid-gutter: 1 2;
    grid-rows: 2 3 3 1; /* need the two lines for the label */
    padding: 1 3;
    border: $border-style $border;
    max-height: 16;
  }
  #question_container {
    column-span: 2;
    height: 1fr;
    width: 1fr;
    content-align: center middle;
    .question {
      content-align: center middle;
      width: 1fr;
      height: 1fr;
      text-align: center;
    }
  }
  Button { width: 100% }
  HorizontalGroup {
    column-span: 2;
    align: center middle;
    Button#cancel { width: 50% }
  }
  #dontAskAgain {
    column-span: 2;
    content-align: center middle;
    align: center middle;
    Switch {
      border: none;
      padding: 0;
      background: transparent;
      margin: 0 2 0 0;
      &:focus {
        border: none;
        & > .switch--slider { color: $panel-lighten-1 }
        &.-on > .switch--slider { color: $success-lighten-1 }
      }
    }
  }
}

FileInUse {
  align: center middle;
  #dialog {
    grid-size: 1;
    grid-gutter: 1 2;
    grid-rows: 1fr 3; /* take up all the space available like Dismissable */
    padding: 1 3;
    border: $border-style $border;
    max-height: 16;
  }
  #question_container {
    column-span: 2;
    height: 1fr;
    width: 1fr;
    content-align: center middle;
    .question {
      content-align: center middle;
      width: 1fr;
      height: 1fr;
      text-align: center;
    }
  }
  Container { align: center middle }
  Button { width: 50% }
  HorizontalGroup { column-span: 2; align: center middle }
}

DeleteFiles {
  align: center middle;
  #dialog {
    grid-size: 2;
    grid-gutter: 1 2;
    grid-rows: 1fr 3 3 1; /* no issues for now */
    padding: 1 3;
    border: $border-style $border;
  }
  #question {
    column-span: 2;
    height: 1fr;
    width: 1fr;
    content-align: center middle;
  }
  Button { width: 100% }
  Container {
    column-span: 2;
    align: center middle;
    Button#cancel { width: 50% }
  }
}

ModalInput {
  align: center middle;
  HorizontalGroup {
    border: $border-style $border;
    width: 50vw;
    max-height: 3;
    padding: 0 1;
    background: transparent !important;
    border-title-align: left;
    border-subtitle-align: right;
    &.invalid { border: $border-style $error-lighten-3 }
    &:light { border: $border-style $error }
  }
  Input {
    background: transparent !important;
    scrollbar-size: 0 0;
    overflow-x: scroll;
  }
  Label { height: 1 }
}

TerminalTooSmall {
  align: center middle;
  background: transparent;
  height: 1fr;
  scrollbar-size: 0 0;
  #logo { offset: 0 -1 }
  HorizontalGroup {
    width: auto;
    background: transparent;
    align: center middle;
  }
  & > Static { height: 1fr }
  #logo.hidden {
    color: $error;
    display: block;
    height: 1fr;
    offset: 0 0;
  }
}


CommandPalette {
  align: center middle;
  CommandList {
    border: $border-style $border;
    border-top: none;
    max-height: 50vh;
    & > .option-list--option-highlighted {
      color: $background;
      background: $primary;
    }
  }
  SearchIcon {
    margin-left: 2;
    margin-top: 1;
  }
  & > Vertical {
    background: transparent;
    width: 50vw;
    height: 50vh;
    margin-top: 0;
  }
  #--input { border: $border-style $border }
  #--input.--list-visible { border-bottom: none }
  LoadingIndicator { border-bottom: $border-style $border }
}

Screen {
  &.-filelistonly {
    #pinned_sidebar_container,
    #preview_sidebar,
    #below_menu Button { display: none !important }
    #below_menu PathAutoCompleteInput { margin: -1 1 0 1 !important }
    #zoxide_group,
    CommandPalette > Vertical,
    #dialog,
    ModalInput {
      width: 90vw;
      max-width: 90vw;
    }
  }
  &.-nopreview {
    #preview_sidebar,
    #below_menu Button { display: none !important }
    #below_menu PathAutoCompleteInput { margin: -1 1 0 1 !important }
    #pinned_sidebar_container { max-width: 25vw }
    #zoxide_group,
    CommandPalette > Vertical,
    #dialog,
    ModalInput {
      width: 75vw;
      max-width: 75vw;
    }
  }
  &.-all-vertical #footer { max-height: 25vh }
  &.-nopath {
    #below_menu { display: none !important }
    #footer { max-height: 30vh }
  }
  &.-nomenu-atall {
    #menu,
    #below_menu { display: none !important }
    #footer { max-height: 30vh }
  }
  &.-filelistonly-vertical {
    #menu { display: none !important }
  }
  &.-middle-only {
    #menu,
    #below_menu { display: none !important }
    #footer { max-height: 25vh }
  }
}
FileListRightClickOptionList {
  width: auto;
  .option-list--option-highlighted {
    background: $primary;
    color: $background;
  }
}
LoadingIndicator {
  background: transparent;
}
