/* Modal Dialogs */

@use "../../../../theme";
@use "../../../../theme-color";
@use "../../../../shadow";
@use "../../gnome-shell";
@use "../../typography";
@use "../base/button";
@use "../base/entry";

.headline {
  @include typography.headline6;
}

.modal-dialog {
  border: 0;
  border-radius: theme.$corner-radius;
  box-shadow: shadow.$z8;
  background-color: theme-color.$surface-z8;
  color: theme-color.$on-surface;

  @if gnome-shell.$version >= 3.36 {
    .modal-dialog-content-box {
      max-width: 28em;
      margin: 32px 40px;
      spacing: 32px;
    }
  } @else {
    .modal-dialog-content-box {
      padding: 24px;
    }
  }

  .modal-dialog-linked-button {
    @extend %bubble_button;
  }

  @if gnome-shell.$version == 3.34 {
    StEntry {
      @extend %entry;
    }

    .button {
      @extend %button;
    }
  }
}

/* End Session Dialog */
@if gnome-shell.$version >= 3.36 {
  .end-session-dialog {
    width: 30em;

    .end-session-dialog-battery-warning,
    .dialog-list-title {
      color: theme-color.$error;
    }
  }
} @else {
  .end-session-dialog {
    spacing: 42px;
    border: 0;
  }

  .end-session-dialog-subject {
    @include typography.headline6;
  }

  .end-session-dialog-list {
    padding-top: 20px;
  }

  .end-session-dialog-layout {
    padding-left: 17px;

    &:rtl {
      padding-right: 17px;
    }
  }

  .end-session-dialog-description {
    width: 28em;
    padding-bottom: 10px;

    &:rtl {
      text-align: right;
    }
  }

  .end-session-dialog-warning {
    width: 28em;
    padding-top: 6px;
    color: theme-color.$error;

    &:rtl {
      text-align: right;
    }
  }

  .end-session-dialog-logout-icon {
    width: 48px;
    height: 48px;
    border-radius: theme.$circular-radius;
    background-size: contain;
  }

  .end-session-dialog-shutdown-icon {
    width: 48px;
    height: 48px;
    color: theme-color.hint(theme-color.$on-surface);
  }

  .end-session-dialog-inhibitor-layout {
    max-height: 200px;
    padding-right: 64px;
    padding-left: 64px;
    spacing: 16px;
  }

  .end-session-dialog-session-list,
  .end-session-dialog-app-list {
    spacing: 1em;
  }

  .end-session-dialog-list-header {
    font-weight: bold;

    &:rtl {
      text-align: right;
    }
  }

  .end-session-dialog-app-list-item,
  .end-session-dialog-session-list-item {
    spacing: 1em;
  }

  .end-session-dialog-app-list-item-name,
  .end-session-dialog-session-list-item-name {
    font-weight: bold;
  }

  .end-session-dialog-app-list-item-description {
    color: theme-color.hint(theme-color.$on-surface);
    font-size: 1em;
  }
}

/* Message Dialog */
@if gnome-shell.$version >= 3.36 {
  .message-dialog-content {
    spacing: 18px;

    .message-dialog-title {
      @include typography.headline6;
      text-align: inherit;

      $lightweight: if(gnome-shell.$version >= 3.38, ".lightweight", ".leightweight");

      &#{$lightweight} {
        @include typography.headline6;
      }
    }

    .message-dialog-description {
      color: theme-color.hint(theme-color.$on-surface);
      text-align: inherit;
    }
  }
} @else {
  .message-dialog-main-layout {
    padding: 12px 20px 0;
    spacing: 12px;
  }

  .message-dialog-content {
    max-width: 28em;
    spacing: 20px;
  }

  .message-dialog-icon {
    min-width: 48px;
    icon-size: 48px;
  }

  .message-dialog-title {
    font-weight: bold;
  }

  .message-dialog-subtitle {
    color: theme-color.hint(theme-color.$on-surface);
    font-weight: normal;
  }
}

/* Dialog List */
.dialog-list {
  spacing: 18px;

  .dialog-list-title {
    text-align: inherit;
    font-weight: bold;
  }

  .dialog-list-scrollview {
    max-height: 200px;
  }

  .dialog-list-box {
    spacing: 1em;

    .dialog-list-item {
      spacing: 1em;

      .dialog-list-item-title {
        font-weight: bold;
      }

      .dialog-list-item-description {
        color: theme-color.hint(theme-color.$on-surface);
        font-size: 1em;
      }
    }
  }
}

/* Run Dialog */
.run-dialog {
  @if gnome-shell.$version >= 3.36 {
    .modal-dialog-content-box {
      margin-top: 24px;
      margin-bottom: 16px;
    }

    .run-dialog-entry {
      width: 20em;
    }

    .run-dialog-description {
      text-align: inherit;
      color: theme-color.hint(theme-color.$on-surface);
      font-size: 1em;
    }
  } @else {
    .run-dialog-label {
      padding-bottom: .4em;
      color: theme-color.hint(theme-color.$on-surface);
      font-weight: normal;
      font-size: 1em;
    }

    .run-dialog-entry {
      width: 20em;
      margin-bottom: 0;
    }

    .run-dialog-error-box {
      padding-top: 16px;
      spacing: 6px;
      color: theme-color.$error;
    }

    .run-dialog-button-box {
      padding-top: 1em;
    }
  }
}

/* Password or Authentication Dialog */

@if gnome-shell.$version >= 3.36 {
  .prompt-dialog {
    width: 28em;

    .modal-dialog-content-box {
      margin-bottom: 24px;
    }
  }

  .prompt-dialog-password-grid {
    spacing-rows: 8px;
    spacing-columns: 4px;

    .prompt-dialog-password-entry {
      width: auto;

      // 4px (spacing) + 16px (spinner-width)
      &:ltr {
        margin-left: 20px;
      }

      &:rtl {
        margin-right: 20px;
      }
    }
  }

  .prompt-dialog-password-layout {
    spacing: 8px;
  }

  .prompt-dialog-password-entry {
    width: 18em;
  }
} @else {
  .prompt-dialog {
    // this is the width of the entire modal popup
    width: 34em;

    .message-dialog-main-layout {
      spacing: 24px;
      padding: 10px;
    }

    .message-dialog-content {
      spacing: 16px;
    }

    .message-dialog-title {
      color: inherit;
      @include typography.headline6;
    }
  }

  .prompt-dialog-description:rtl {
    text-align: right;
  }

  .prompt-dialog-password-box {
    spacing: 1em;
    padding-bottom: 1em;
  }
}

.prompt-dialog-error-label,
.prompt-dialog-info-label,
.prompt-dialog-null-label {
  font-size: 1em;

  @if gnome-shell.$version >= 3.36 {
    text-align: inherit;
  } @else {
    padding-bottom: 8px;
  }
}

.prompt-dialog-error-label {
  color: theme-color.$error;
}

@if gnome-shell.$version == 3.34 {
  .prompt-dialog-pim-box {
    spacing: 1em;
  }

  .prompt-dialog-grid {
    spacing-rows: 15px;
    spacing-columns: 1em;
  }

  .prompt-dialog-keyfiles-box {
    spacing: 1em;
  }

  .prompt-dialog-button.button {
    padding: 0 8px;
  }
}


/* Polkit Dialog */

.polkit-dialog-user-layout {
  @if gnome-shell.$version >= 3.36 {
    text-align: center;
    spacing: 8px;
    margin-bottom: 6px;
  } @else {
    spacing: 10px;
    padding-left: 10px;

    &:rtl {
      padding-left: 0;
      padding-right: 10px;
    }
  }

  @if gnome-shell.$version < 40 {
    .polkit-dialog-user-icon {
      border-radius: theme.$circular-radius;
      background-size: contain;

      @if gnome-shell.$version < 3.36 {
        width: 48px;
        height: 48px;
      }
    }
  }

  .polkit-dialog-user-root-label {
    color: theme-color.$error;
  }
}

/* Audio selection dialog */
.audio-device-selection-dialog {
  @if gnome-shell.$version >= 3.36 {
    .modal-dialog-content-box {
      margin-bottom: 28px;
    }
  } @else {
    spacing: 30px;

    .audio-selection-content {
      spacing: 20px;
      padding: 24px;
    }

    .audio-selection-title {
      font-weight: bold;
      text-align: inherit;
    }
  }

  .audio-selection-box {
    spacing: 20px;
  }
}

.audio-selection-device {
  transition-duration: theme.$state-duration;
  border: 0;
  border-radius: theme.$corner-radius;

  &:focus {
    background-color: theme-color.focus-overlay(theme-color.$on-surface);
  }

  &:hover {
    background-color: theme-color.hover-overlay(theme-color.$on-surface);
  }

  &:active {
    transition-duration: theme.$ripple-duration;
    background-color: theme-color.pressed-overlay(theme-color.$on-surface);
    color: inherit;
  }
}

.audio-selection-device-box {
  padding: 20px;
  spacing: 20px;
}

.audio-selection-device-icon {
  icon-size: 64px;
}

@if gnome-shell.$version >= 40 {
  /* Welcome dialog */
  .welcome-dialog-image {
    // Reasonable maximum dimensions
    height: 300px;
    width: 300px;
    background-image: url("gnome-shell-start.svg");
    background-size: contain;
  }
}

@if gnome-shell.$version < 3.36 {
  /* ShellMountOperation Dialogs */
  .shell-mount-operation-icon {
    icon-size: 48px;
  }

  .mount-dialog-subject {
    @include typography.headline6;
  }

  .mount-dialog {
    spacing: 24px;

    .message-dialog-title {
      max-width: 34em;
      padding-top: 10px;
      padding-bottom: 6px;
      padding-left: 17px;

      &:rtl {
        padding-left: 0;
        padding-right: 17px;
      }
    }

    .message-dialog-body {
      width: 28em;
      padding-left: 17px;

      &:rtl {
        padding-left: 0;
        padding-right: 17px;
      }
    }
  }

  .mount-dialog-app-list {
    max-height: 200px;
    padding-top: 24px;
    padding-left: 48px;
    padding-right: 32px;

    &:rtl {
      padding-right: 48px;
      padding-left: 32px;
    }
  }

  .mount-dialog-app-list-item {
    &,
    &:hover {
      color: inherit;
    }

    &:ltr {
      padding-right: 1em;
    }

    &:rtl {
      padding-left: 1em;
    }
  }

  .mount-dialog-app-list-item-icon {
    &:ltr {
      padding-right: 16px;
    }

    &:rtl {
      padding-left: 16px;
    }
  }

  .mount-dialog-app-list-item-name {
    font-size: 1em;
  }

  /* Access Dialog */
  .access-dialog {
    spacing: 30px;
  }

  /* Geolocation Dialog */
  .geolocation-dialog {
    spacing: 30px;
  }

  /* Extension Dialog */
  .extension-dialog {
    .message-dialog-main-layout {
      spacing: 24px;
      padding: 10px;
    }

    .message-dialog-title {
      color: theme-color.hint(theme-color.$on-surface);
      font-weight: normal;
    }
  }

  /* Inhibit-Shortcuts Dialog */
  .inhibit-shortcuts-dialog {
    spacing: 30px;
  }

  /* Network Agent Dialog */

  .network-dialog-secret-table {
    spacing-rows: 15px;
    spacing-columns: 1em;
  }

  .keyring-dialog-control-table {
    spacing-rows: 15px;
    spacing-columns: 1em;
  }
}
