/*!
 * copyright   Copyright (C) 2010-2021 Combodo SARL
 * license     http://opensource.org/licenses/AGPL-3.0
 */

/* SCSS variables */
$ibo-field--sibling-spacing: 16px !default;
$ibo-field--value--color: $ibo-color-grey-700 !default;

$ibo-field--label--description--content: "?" !default;
$ibo-field--label--description--padding-left: 4px !default;
$ibo-field--label--description--color: $ibo-color-grey-600 !default;

$ibo-field--background-color--is-fullscreen: $ibo-color-white-100 !default;

$ibo-field--label--width--is-fullscreen: 100% !default;
$ibo-field--label--padding-x--is-fullscreen: 8px !default;
$ibo-field--label--padding-y--is-fullscreen: 4px !default;
$ibo-field--label--background-color--is-fullscreen: $ibo-color-grey-100 !default;
$ibo-field--label--border-bottom--is-fullscreen: 1px solid $ibo-color-grey-400 !default;

$ibo-field--fullscreen-toggler--size: 20px !default;
$ibo-field--fullscreen-toggler--border-radius: $ibo-border-radius-500 !default;
$ibo-field--fullscreen-toggler--background-color--on-hover: $ibo-color-white-200 !default;

$ibo-field--value--padding-x--is-fullscreen: $ibo-field--label--padding-x--is-fullscreen !default;
$ibo-field--value--padding-top--is-fullscreen: $ibo-field--label--padding-y--is-fullscreen + 32px !default;
$ibo-field--value--padding-bottom--is-fullscreen: $ibo-field--label--padding-y--is-fullscreen !default;

$ibo-field--value-decoration--spacing-x: 0.5rem !default;

/* SCSS rules */
.ibo-field {
  @extend %ibo-font-ral-nor-150;

  & ~ .ibo-field {
    margin-top: $ibo-field--sibling-spacing;
  }
}

.ibo-field-large {
  display: inherit;

  .ibo-field--label {
    position: relative; /* Necessary for fullscreen toggler */
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: initial;
    width: 100%;
  }
}
.ibo-field-small {
  display: table;
  width: 100%;

  .ibo-field--label {
    display: table-cell;
    vertical-align: top;
    padding-right: 10px;
  }
}

.ibo-field--label {
  min-width: 100px;
  max-width: 145px;
  width: 30%;

  > .ibo-has-description {
    &::after {
      content: $ibo-field--label--description--content;
      padding-left: $ibo-field--label--description--padding-left;
      vertical-align: top;

      cursor: pointer;
      color: $ibo-field--label--description--color;
      @extend %ibo-font-ral-bol-50;
    }
  }
}
.ibo-field--fullscreen-toggler {
  width: $ibo-field--fullscreen-toggler--size;
  height: $ibo-field--fullscreen-toggler--size;
  border-radius: $ibo-field--fullscreen-toggler--border-radius;
  cursor: pointer;

  @extend %ibo-hyperlink-inherited-colors;
  @extend %ibo-fully-centered-content;
  @extend %ibo-font-ral-nor-100;

  &:hover {
    background-color: $ibo-field--fullscreen-toggler--background-color--on-hover;
  }
}
.ibo-field--value {
  display: table;
  width: 100%;
  color: $ibo-field--value--color;

  /* Hack to force a table to fit its container without overflow (see N°2127) */
  /* Note that along with with, we now display a "expand" icon on large fields so we can have a better view of its content */
  .HTML {
    table {
      table-layout: fixed;
      width: 100%;
    }
  }
}

.ibo-field--comments {
  display: table-cell;
  vertical-align: top;
  padding-right: 10px;

  > input[type="checkbox"] {
    margin-left: 5px;
  }
}

.multi_values, .mono_value {
  display: inline-block;
  padding-left: 5px;
}

/* Fullscreen mode */
.ibo-field-large {
  &.ibo-is-fullscreen {
    background-color: $ibo-field--background-color--is-fullscreen;

    .ibo-field--label {
      position: fixed;
      width: $ibo-field--label--width--is-fullscreen;
      min-width: initial;
      max-width: initial;
      padding: $ibo-field--label--padding-y--is-fullscreen $ibo-field--label--padding-x--is-fullscreen;
      background-color: $ibo-field--label--background-color--is-fullscreen;
      border-bottom: $ibo-field--label--border-bottom--is-fullscreen;
    }

    .ibo-field--value {
      padding: $ibo-field--value--padding-top--is-fullscreen $ibo-field--value--padding-x--is-fullscreen $ibo-field--value--padding-bottom--is-fullscreen $ibo-field--value--padding-x--is-fullscreen;
    }
  }
}

.mailto, .tel {
  white-space: nowrap;

  .text_decoration {
    margin-right: $ibo-field--value-decoration--spacing-x;
  }
}

.object-ref-icon, .object-ref-icon-disabled {
  &.text_decoration {
    margin-right: $ibo-field--value-decoration--spacing-x;
    @extend %ibo-font-ral-nor-100;
  }
}
