/* Copyright (c) Ansible and contributors */

.ansible-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;

  > a {
    padding: 4px 12px;
    margin: 2px 4px;

    cursor: pointer;
    border-radius: 3px;

    background-color: #5bbdbf;
    color: white;

    &:hover, &:active, &:focus {
      background-color: #91d9db;
    }

    &:focus {
      outline: 3px solid #204748;
    }
  }
}

// Documentation table (for module options and return values)
table.documentation-table {
  border-bottom: 1px solid #000;
  border-right: 1px solid #000;

  th {
    background-color: #6AB0DE;
  }

  td, th {
    padding: 4px;
    border-left: 1px solid #000;
    border-top: 1px solid #000;
  }

  td.elbow-placeholder {
    border-top: 0;
    width: 30px;
    min-width: 30px;
  }

  // More table formatting
  td {
    vertical-align: top;
  }
  td:first-child {
    white-space: nowrap;
  }

  // Direct links to options / return values
  tr {
    .ansibleOptionLink {
      display: inline-block;
      visibility: hidden;

      &::after {
        content: "🔗";
      }
    }

    &:hover .ansibleOptionLink::after {
      visibility: visible;
    }

    &:nth-child(odd) {
      background-color: #FFFFFF;
    }
    &:nth-child(even) {
      background-color: #E7F2FA;
    }
  }
}

table.ansible-option-table {
  // This is the default, but for some reason sphinx_ansible_theme sets this to 'display: block',
  // which totally wrecks the layout. (The height 'hack' below then ensures that the table actually
  // has height 1px, which basically hides it.)
  display: table;

  border-color: #000000 !important;
  
  // The following is basically ignored, but together with the `height: 100%` for <tr>
  // and the two `height: inherit`s for <td> and <div> makes sure that the <div> inside
  // the <td> has full height.
  height: 1px;

  tr {
    height: 100%;
  }

  td, th {
    border-color: #000000 !important;
    border-bottom: none !important;
    vertical-align: top !important;
  }

  th > p {
    font-size: initial !important;
  }

  thead tr {
    background-color: #6AB0DE;
  }

  tbody {
    .row-odd td {
      background-color: #FFFFFF !important;
    }

    .row-even td {
      background-color: #E7F2FA !important;
    }
  }

  ul > li > p {
    margin: 0 !important;
  }

  ul > li > div[class^="highlight"] {
    margin-bottom: 4px !important;
  }

  p.ansible-option-title {
    display: inline;
  }

  .ansible-option-type-line {
    font-size: small;
    margin-bottom: 0;
  }

  .ansible-option-type {
    color: purple;
  }

  .ansible-option-elements {
    color: purple;
  }

  .ansible-option-required {
    color: red;
  }

  .ansible-option-versionadded {
    font-style: italic;
    font-size: small;
    color: darkgreen;
  }

  .ansible-option-aliases {
    color: darkgreen;
  }

  .ansible-option-line {
    margin-top: 8px;
  }

  .ansible-option-choices {
    font-weight: 700;
  }

  .ansible-option-choices-entry {
  }

  .ansible-option-default {
    color: blue;
  }

  .ansible-option-default-bold {
    color: blue;
    font-weight: 700;
  }

  .ansible-option-returned-bold {
    font-weight: 700;
  }

  .ansible-option-sample {
    color: blue;
    word-wrap: break-word;
    word-break: break-all;
  }

  .ansible-option-sample-bold {
    color: black;
    font-weight: 700;
  }

  .ansible-option-configuration {
    font-weight: 700;
  }

  .ansibleOptionLink {
    display: inline-block;
    visibility: hidden;

    &::after {
      content: "🔗";
    }
  }

  p {
    margin: 0 0 8px;
  }

  tr:hover .ansibleOptionLink::after {
    visibility: visible;
  }

  td {
    padding: 0 !important;
    white-space: normal;

    > div.ansible-option-cell  {
      padding: 8px 16px;
      border-top: 1px solid #000000;
    }
  }

  td:first-child {
    height: inherit;
    display: flex;
    flex-direction: row;

    > div.ansible-option-cell  {
      height: inherit;
      flex: 1 0 auto;
      white-space: nowrap;
    }
  }

  .ansible-option-indent {
    margin-left: 2em;
    border-right: 1px solid #000000;
  }

  .ansible-attribute-support-label {
    display: none;
  }

  .ansible-attribute-support-label, .ansible-attribute-support-property {
    font-weight: bold;
  }

  .ansible-attribute-support-none {
    font-weight: bold;
    color: red;
  }

  .ansible-attribute-support-partial {
    font-weight: bold;
    color: #a5a500;
  }

  .ansible-attribute-support-full {
    font-weight: bold;
    color: green;
  }

  .ansible-attribute-support-na {
  }

  .ansible-attribute-details {
    font-style: italic;
  }
}

@media (max-width: 1200px) {
  table.ansible-option-table {
    display: block;
    height: unset;
    border: none !important;
  
    thead {
      display: none;
    }
  
    tbody, tr, td {
      display: block;
      border: none !important;
    }

    tbody {
      .row-odd td {
        background-color: unset !important;
      }

      .row-even td {
        background-color: unset !important;
      }
    }

    td {
      > div.ansible-option-cell {
        border-top: none;
      }

      &:first-child > div.ansible-option-cell {
        background-color: #E7F2FA !important;
      }
    }

    td:not(:first-child) {
      display: flex;
      flex-direction: row;
      
      > div.ansible-option-cell {
        margin-left: 1em;
      }
    }

    .ansible-option-indent, .ansible-option-indent-desc {
      margin-left: 1em;
    }

    .ansible-option-indent, .ansible-option-indent-desc {
      border: none;
      border-right: solid 3px #E7F2FA;
    }

    .ansible-attribute-support-label {
      display: unset;
    }
  }
}
