@import '../../themes/default/modules/modal.variables';

@if $use-modal {
  /*******************************
  //@-         Modal
  *******************************/

  .ui.modal {
    position: absolute;
    display: none;
    z-index: $modal-z-index;
    text-align: left;

    background: $modal-background;
    border: $modal-border;
    box-shadow: $modal-box-shadow;
    transform-origin: $modal-transform-origin;

    flex: 0 0 auto;

    border-radius: $modal-border-radius;
    user-select: text;
    will-change: top, left, margin, transform, opacity;
  }

  .ui.modal > :first-child:not(.icon):not(.dimmer),
  .ui.modal > .icon:first-child + *,
  .ui.modal > .dimmer:first-child + *:not(.icon),
  .ui.modal > .dimmer:first-child + .icon + * {
    border-top-left-radius: $modal-border-radius;
    border-top-right-radius: $modal-border-radius;
  }

  .ui.modal > :last-child {
    border-bottom-left-radius: $modal-border-radius;
    border-bottom-right-radius: $modal-border-radius;
  }

  /*******************************
              Content
  *******************************/

  /*--------------
      Close
  ---------------*/

  .ui.modal > .close {
    cursor: pointer;
    position: absolute;
    top: $modal-close-top;
    right: $modal-close-right;
    z-index: 1;

    opacity: $modal-close-opacity;
    font-size: $modal-close-size;
    color: $modal-close-color;

    width: $modal-close-hitbox;
    height: $modal-close-hitbox;
    padding: $modal-close-padding;
  }
  .ui.modal > .close:hover {
    opacity: 1;
  }

  /*--------------
      Header
  ---------------*/

  .ui.modal > .header {
    display: block;
    font-family: $modal-header-font-family;
    background: $modal-header-background;
    margin: $modal-header-margin;
    padding: $modal-header-padding;
    box-shadow: $modal-header-box-shadow;

    color: $modal-header-color;
    border-bottom: $modal-header-border;
  }
  .ui.modal > .header:not(.ui) {
    font-size: $modal-header-font-size;
    line-height: $header-line-height;
    font-weight: $modal-header-font-weight;
  }

  /*--------------
      Content
  ---------------*/

  .ui.modal > .content {
    display: block;
    width: 100%;
    font-size: $modal-content-font-size;
    line-height: $modal-content-line-height;
    padding: $modal-content-padding;
    background: $modal-content-background;
  }
  .ui.modal > .image.content {
    display: flex;
    flex-direction: row;
  }

  /* Image */
  .ui.modal > .content > .image {
    display: block;
    flex: 0 1 auto;
    width: $modal-image-width;
    align-self: $modal-image-vertical-align;
    max-width: 100%;
  }
  .ui.modal > [class*="top aligned"] {
    align-self: start;
  }
  .ui.modal > [class*="middle aligned"] {
    align-self: center;
  }
  .ui.modal > [class*="stretched"] {
    align-self: stretch;
  }

  /* Description */
  .ui.modal > .content > .description {
    display: block;
    flex: 1 0 auto;
    min-width: 0;
    align-self: $modal-description-vertical-align;
  }

  .ui.modal > .content > .icon + .description,
  .ui.modal > .content > .image + .description {
    flex: 0 1 auto;
    min-width: $modal-description-min-width;
    width: $modal-description-width;
    padding-left: $modal-description-distance;
  }

  /*rtl:ignore*/
  .ui.modal > .content > .image > i.icon {
    margin: 0;
    opacity: 1;
    width: auto;
    line-height: 1;
    font-size: $modal-image-icon-size;
  }

  /*--------------
      Actions
  ---------------*/

  .ui.modal > .actions {
    background: $modal-action-background;
    padding: $modal-action-padding;
    border-top: $modal-action-border;
    text-align: $modal-action-align;
  }
  .ui.modal .actions > .button {
    margin-left: $modal-button-distance;
  }
  .ui.basic.modal > .actions {
    border-top:none;
  }

  /*-------------------
        Responsive
  --------------------*/

  /* Modal Width */
  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.modal:not(.fullscreen) {
      width: calc(#{$modal-mobile-width} - 1px);
      margin: $modal-mobile-margin;
    }
  }
  @media only screen and (min-width : $tablet-breakpoint) {
    .ui.modal:not(.fullscreen) {
      width: calc(#{$modal-tablet-width} - 1px);
      margin: $modal-tablet-margin;
    }
  }
  @media only screen and (min-width : $computer-breakpoint) {
    .ui.modal:not(.fullscreen) {
      width: $modal-computer-width;
      margin: $modal-computer-margin;
    }
  }
  @media only screen and (min-width : $large-monitor-breakpoint) {
    .ui.modal:not(.fullscreen) {
      width: $modal-large-monitor-width;
      margin: $modal-large-monitor-margin;
    }
  }
  @media only screen and (min-width : $widescreen-monitor-breakpoint) {
    .ui.modal:not(.fullscreen) {
      width: $modal-widescreen-monitor-width;
      margin: $modal-widescreen-monitor-margin;
    }
  }

  /* Tablet and Mobile */
  @media only screen and (max-width : $largest-tablet-screen) {
    .ui.modal > .header {
      padding-right: $modal-close-hitbox;
    }
    .ui.modal > .close {
      top: $modal-inner-close-top;
      right: $modal-inner-close-right;
      color: $modal-inner-close-color;
    }
  }

  /* Mobile */
  @media only screen and (max-width : $largest-mobile-screen) {

    .ui.modal > .header {
      padding: $modal-mobile-header-padding !important;
      padding-right: $modal-close-hitbox !important;
    }
    .ui.overlay.fullscreen.modal > .content.content.content {
      min-height: $modal-overlay-fullscreen-scrolling-content-max-height-mobile;
    }
    .ui.overlay.fullscreen.modal > .scrolling.content.content.content {
      max-height: $modal-overlay-fullscreen-scrolling-content-max-height-mobile;
    }
    .ui.modal > .content {
      display: block;
      padding: $modal-mobile-content-padding !important;
    }
    .ui.modal > .close {
      top: $modal-mobile-close-top !important;
      right: $modal-mobile-close-right !important;
    }

    /*rtl:ignore*/
    .ui.modal .image.content {
      flex-direction: column;
    }
    .ui.modal .content > .image {
      display: block;
      max-width: 100%;
      margin: 0 auto !important;
      text-align: center;
      padding: $modal-mobile-image-padding !important;
    }
    .ui.modal > .content > .image > i.icon {
      font-size: $modal-mobile-image-icon-size;
      text-align: center;
    }

    /*rtl:ignore*/
    .ui.modal .content > .description {
      display: block;
      width: 100% !important;
      margin: 0 !important;
      padding: $modal-mobile-description-padding !important;
      box-shadow: none;
    }

    /* Let Buttons Stack */
    .ui.modal > .actions {
      padding: $modal-mobile-action-padding !important;
    }
    .ui.modal .actions > .buttons,
    .ui.modal .actions > .button {
      margin-bottom: $modal-mobile-button-distance;
    }
  }

  /*--------------
      Coupling
  ---------------*/

  .ui.inverted.dimmer > .ui.modal {
    box-shadow: $modal-inverted-box-shadow;
  }

  /*******************************
              Types
  *******************************/

  @if($use-modal-type-basic) {
    .ui.basic.modal {
      background-color: transparent;
      border: none;
      border-radius: 0;
      box-shadow: none !important;
      color: $modal-basic-color;
    }
    .ui.basic.modal > .header,
    .ui.basic.modal > .content,
    .ui.basic.modal > .actions {
      background-color: transparent;
    }
    .ui.basic.modal > .header {
      color: $modal-basic-header-color;
    }
    .ui.basic.modal > .close {
      top: $modal-basic-close-top;
      right: $modal-basic-close-right;
      color: $modal-basic-inner-close-color;
    }

    .ui.inverted.dimmer > .basic.modal {
      color: $modal-basic-inverted-color;
    }
    .ui.inverted.dimmer > .ui.basic.modal > .header {
      color: $modal-basic-inverted-header-color;
    }
  }

  /* Resort to margin positioning if legacy */
  .ui.legacy.legacy.modal,
  .ui.legacy.legacy.page.dimmer > .ui.modal {
    left: 50% !important;
  }
  .ui.legacy.legacy.modal:not(.aligned),
  .ui.legacy.legacy.page.dimmer > .ui.modal:not(.aligned) {
    top: 50%;
  }
  .ui.legacy.legacy.page.dimmer > .ui.scrolling.modal:not(.aligned),
  .ui.page.dimmer > .ui.scrolling.legacy.legacy.modal:not(.aligned),
  .ui.top.aligned.legacy.legacy.page.dimmer > .ui.modal:not(.aligned),
  .ui.top.aligned.dimmer > .ui.legacy.legacy.modal:not(.aligned) {
    top: auto;
  }

  .ui.legacy.overlay.fullscreen.modal {
    margin-top: -$modal-scrolling-margin !important;
  }

  /*******************************
              States
  *******************************/

  .ui.loading.modal {
    display: block;
    visibility: hidden;
    z-index: $modal-loading-z-index;
  }

  .ui.active.modal {
    display: block;
  }

  /*******************************
            Variations
  *******************************/

  /*--------------
    Aligned
  ---------------*/

  .ui.top.aligned.modal {
    top: $modal-top-aligned-margin;
  }
  .ui.bottom.aligned.modal {
    bottom: $modal-bottom-aligned-margin;
  }

  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.top.aligned.modal {
      top: $modal-mobile-top-aligned-margin;
    }
    .ui.bottom.aligned.modal {
      bottom: $modal-mobile-bottom-aligned-margin;
    }
  }


  /*--------------
      Scrolling
  ---------------*/

  /* Scrolling Dimmer */
  .scrolling.dimmable.dimmed {
    overflow: hidden;
  }
  .scrolling.dimmable > .dimmer {
    justify-content: flex-start;
    position: fixed;
  }
  .scrolling.dimmable.dimmed > .dimmer {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modals.dimmer .ui.scrolling.modal:not(.fullscreen) {
    margin: $modal-scrolling-margin auto;
  }

  /* Undetached Scrolling */
  .scrolling.undetached.dimmable.dimmed {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .scrolling.undetached.dimmable.dimmed > .dimmer {
    overflow: hidden;
  }
  .scrolling.undetached.dimmable .ui.scrolling.modal:not(.fullscreen) {
    position: absolute;
    left: 50%;
    margin-top: $modal-scrolling-margin !important;
  }

  /* Scrolling Content */
  .ui.modal > .scrolling.content {
    max-height: $modal-scrolling-content-max-height;
    overflow: auto;
  }
  .ui.overlay.fullscreen.modal > .content {
    min-height: $modal-overlay-fullscreen-scrolling-content-max-height;
  }
  .ui.overlay.fullscreen.modal > .scrolling.content {
    max-height: $modal-overlay-fullscreen-scrolling-content-max-height;
  }

  @if($use-modal-type-fullscreen) {
    /*--------------
      Full Screen
    ---------------*/

    .ui.fullscreen.modal {
      width: $modal-full-screen-width;
      left: $modal-full-screen-offset;
      margin: $modal-full-screen-margin;
    }
    .ui.overlay.fullscreen.modal {
      width: 100%;
      left: 0;
      margin: 0 auto;
      top: 0;
      border-radius:0;
    }
    .ui.fullscreen.modal > .header {
      padding-right: $modal-close-hitbox;
    }
    .ui.fullscreen.modal > .close {
      top: $modal-inner-close-top;
      right: $modal-inner-close-right;
      color: $modal-inner-close-color;
    }
    .ui.basic.fullscreen.modal > .close {
      color: $modal-basic-inner-close-color;
    }
  }

  /*--------------
        Size
  ---------------*/

  .ui.modal {
    font-size: $medium;
  }

  /* Mini */
  .ui.mini.modal > .header:not(.ui) {
    font-size: $modal-mini-header-size;
  }

  /* Mini Modal Width */
  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.mini.modal {
      width: $modal-mini-mobile-width;
      margin: $modal-mini-mobile-margin;
    }
  }
  @media only screen and (min-width : $tablet-breakpoint) {
    .ui.mini.modal {
      width: $modal-mini-tablet-width;
      margin: $modal-mini-tablet-margin;
    }
  }
  @media only screen and (min-width : $computer-breakpoint) {
    .ui.mini.modal {
      width: $modal-mini-computer-width;
      margin: $modal-mini-computer-margin;
    }
  }
  @media only screen and (min-width : $large-monitor-breakpoint) {
    .ui.mini.modal {
      width: $modal-mini-large-monitor-width;
      margin: $modal-mini-large-monitor-margin;
    }
  }
  @media only screen and (min-width : $widescreen-monitor-breakpoint) {
    .ui.mini.modal {
      width: $modal-mini-widescreen-monitor-width;
      margin: $modal-mini-widescreen-monitor-margin;
    }
  }

  /* Tiny */
  .ui.tiny.modal > .header:not(.ui) {
    font-size: $modal-tiny-header-size;
  }

  /* Tiny Modal Width */
  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.tiny.modal {
      width: $modal-tiny-mobile-width;
      margin: $modal-tiny-mobile-margin;
    }
  }
  @media only screen and (min-width : $tablet-breakpoint) {
    .ui.tiny.modal {
      width: $modal-tiny-tablet-width;
      margin: $modal-tiny-tablet-margin;
    }
  }
  @media only screen and (min-width : $computer-breakpoint) {
    .ui.tiny.modal {
      width: $modal-tiny-computer-width;
      margin: $modal-tiny-computer-margin;
    }
  }
  @media only screen and (min-width : $large-monitor-breakpoint) {
    .ui.tiny.modal {
      width: $modal-tiny-large-monitor-width;
      margin: $modal-tiny-large-monitor-margin;
    }
  }
  @media only screen and (min-width : $widescreen-monitor-breakpoint) {
    .ui.tiny.modal {
      width: $modal-tiny-widescreen-monitor-width;
      margin: $modal-tiny-widescreen-monitor-margin;
    }
  }

  /* Small */
  .ui.small.modal > .header:not(.ui) {
    font-size: $modal-small-header-size;
  }

  /* Small Modal Width */
  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.small.modal {
      width: $modal-small-mobile-width;
      margin: $modal-small-mobile-margin;
    }
  }
  @media only screen and (min-width : $tablet-breakpoint) {
    .ui.small.modal {
      width: $modal-small-tablet-width;
      margin: $modal-small-tablet-margin;
    }
  }
  @media only screen and (min-width : $computer-breakpoint) {
    .ui.small.modal {
      width: $modal-small-computer-width;
      margin: $modal-small-computer-margin;
    }
  }
  @media only screen and (min-width : $large-monitor-breakpoint) {
    .ui.small.modal {
      width: $modal-small-large-monitor-width;
      margin: $modal-small-large-monitor-margin;
    }
  }
  @media only screen and (min-width : $widescreen-monitor-breakpoint) {
    .ui.small.modal {
      width: $modal-small-widescreen-monitor-width;
      margin: $modal-small-widescreen-monitor-margin;
    }
  }

  /* Large Modal Width */
  .ui.large.modal > .header {
    font-size: $modal-large-header-size;
  }
  @media only screen and (max-width : $largest-mobile-screen) {
    .ui.large.modal {
      width: $modal-large-mobile-width;
      margin: $modal-large-mobile-margin;
    }
  }
  @media only screen and (min-width : $tablet-breakpoint) {
    .ui.large.modal {
      width: $modal-large-tablet-width;
      margin: $modal-large-tablet-margin;
    }
  }
  @media only screen and (min-width : $computer-breakpoint) {
    .ui.large.modal {
      width: $modal-large-computer-width;
      margin: $modal-large-computer-margin;
    }
  }
  @media only screen and (min-width : $large-monitor-breakpoint) {
    .ui.large.modal {
      width: $modal-large-large-monitor-width;
      margin: $modal-large-large-monitor-margin;
    }
  }
  @media only screen and (min-width : $widescreen-monitor-breakpoint) {
    .ui.large.modal {
      width: $modal-large-widescreen-monitor-width;
      margin: $modal-large-widescreen-monitor-margin;
    }
  }


  @if($use-modal-type-inverted) {
    /*****************************
              Inverted
    *******************************/

    .ui.inverted.modal {
      background: $modal-inverted-background;
    }

    .ui.inverted.modal > .header,
    .ui.inverted.modal > .content {
      background: $modal-inverted-background;
      color: $modal-inverted-header-color;
    }

    .ui.inverted.modal > .actions {
      background: $modal-inverted-action-background;
      border-top: $modal-inverted-action-border;
      color: $modal-inverted-action-color;
    }

    .ui.inverted.dimmer > .modal > .close {
      color: $modal-inverted-dimmer-close-color;
    }


    @media only screen and (max-width: $largest-tablet-screen) {
      .ui.dimmer .inverted.modal > .close {
        color: $modal-inverted-close-color;
      }
    }

    .ui.inverted.fullscreen.modal > .close {
      color: $modal-inverted-close-color;
    }
  }
}

@import '../../themes/default/modules/modal.style';