/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

.sub-panel-banner {
  color: $midnight-blue;
}

.sub-panel-banner-text {
  margin-left: 1em;
}

.sub-panel-banner-button:hover {
  background-color: $midnight-blue-transparent;
}


.sub-panel .subpanel-icon svg {
  font-size: x-large;
  fill: $white;
  stroke: $white;
}

.sub-panel div.card {
  margin-top: 0.625rem;
}

.sub-panel .panel-buttons button.btn-outline-light {
  scrm-image {
    display: none;
  }
}

.sub-panel .panel-buttons button.button-group-button.btn-outline-light.active {
  background-color: $midnight-blue;
  color: $white;
  border-color: $midnight-blue;
  font-weight: bold;

  scrm-image {
    display: inline;
  }

  svg {
    fill: $white;
  }
}

.sub-panel .panel-buttons button.button-group-button.btn-outline-light.active:hover {
  background-color: $white;
  color: $midnight-blue;
  border-color: $white;
  fill: $midnight-blue;

  scrm-image {
    display: inline;

    svg {
      fill: $midnight-blue;
    }
  }
}

@media all and (max-width: $breakpoint-small) {
  .sub-panel table td {
    max-width: 100px;
  }
}

div.widget-panel .panel-card .card-header {
  background-color: $white;
  color: $midnight-blue;
  font-weight: bold;
  border-top: 3px solid $midnight-blue;
  padding: 0.5rem 0.6rem;
}

.sub-panel-banner {
  .insight-panel {
    margin-left: 0;
    margin-right: 0;

    .insight-panel-card {
      cursor: pointer;
      padding: 0;
      border: none;
      border-bottom: 1px solid $shell-grey;
      border-radius: 0;
      margin: 0;
      margin-right: 0.5em;
      color: $shell-grey;

      .grid-widget {
        min-height: 2.1em;
        padding-left: 0.5em;
        padding-right: 0.5em;
        height: 100%;
        justify-content: flex-end;
        flex-direction: row !important;
        align-items: start;

        .widget-entry-icon {
          display: flex;
          justify-content: flex-end;
          margin-right: 0.4em;

          svg {
            font-size: 1.5em;
            fill: $shell-grey;
            stroke: $shell-grey;
          }
        }

        .sub-panel-banner-value {
          margin-left: 0.4em;
          min-width: fit-content;

          .widget-entry-value {
            color: $shell-grey;
            font-size: .67rem;
          }

          .skeleton-field-content {
            height: 0.8em;
          }
        }

        .sub-panel-banner-button-title {
          width: 100%;

          .widget-entry-label {
            text-transform: uppercase;
            font-size: .62rem;
            width: 100%;
            padding: .5em 0;
            color: $shell-grey;
          }
        }

      }

      @media (min-width: $breakpoint-medium) {
        &:hover{
          border-bottom: 1px solid $highlight-grey;

          .grid-widget {
            background-color: inherit;

            .widget-entry-icon {
              svg {
                fill: $highlight-grey;
                stroke: $highlight-grey;
              }
            }

            .sub-panel-banner-button-title {
              .widget-entry-label {
                font-size: .62rem;
                color: $highlight-grey;
              }
            }

            .sub-panel-banner-value {
              .widget-entry-value {
                color: $highlight-grey;
              }
            }
          }
        }
      }

      &.sub-panel-banner-button-active {
        border-bottom: 1px solid $bright-purple;

        .grid-widget {
          background-color: inherit;

          .widget-entry-icon {
            svg {
              fill: $bright-purple;
              stroke: $bright-purple;
            }
          }

          .sub-panel-banner-button-title {
            .widget-entry-label {
              font-size: .62rem;
              color: $bright-purple;
              font-weight: 900;
            }
          }

          .sub-panel-banner-value {
            .widget-entry-value {
              color: $bright-purple;
            }
          }
        }
        @media (min-width: $breakpoint-medium) {
          &:hover {
            border-bottom: 1px solid $highlight-purple;

            .grid-widget {
              background-color: inherit;

              .widget-entry-icon {
                svg {
                  fill: $highlight-purple;
                  stroke: $highlight-purple;
                }
              }

              .sub-panel-banner-button-title {
                .widget-entry-label {
                  font-size: .62rem;
                  color: $highlight-purple;
                  font-weight: 900;
                }
              }

              .sub-panel-banner-value {
                .widget-entry-value {
                  color: $highlight-purple;
                }
              }
            }
          }
        }
      }

    }


    @media (min-width: 768px) {
      .col-md-2 {
        flex: 0 0 15.666667%;
        max-width: 15.666667%;
      }
    }


    .sub-panel-banner-tooltip {
      width: 100%;

      .widget-entry-label {
        border-bottom: 2px solid $very-light-grey;
        font-size: 0.7rem;
        line-height: 1rem;

        label {
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          width: 100%;
          margin: 0;
        }
      }

    }


  }

  .sub-panel-banner-body {


    .sub-panel-banner-body-table {
      width: 95%;
      table-layout: fixed;

      .sub-panel-banner-body-table-row:first-child {
        .sub-panel-banner-body-table-col {
          padding-bottom: 0.5em;
        }
      }

      .sub-panel-banner-body-table-row {
        height: 100%;
        .sub-panel-banner-body-table-col {
          height: 100%;

          .insight-panel-card {
            height: 100%;
            display: flex;
          }

          .grid-widget {
            justify-content: flex-end;
            flex-direction: row !important;
            align-items: start;

            .statistics-sidebar-widget-row {
              width: 100%;
              height: 100%;
              min-height: 2.7em;
            }

            .sub-panel-banner-button-title {
              .widget-entry-label {
                text-wrap: auto;
                word-break: normal;
              }
            }
          }
        }
      }

    }
  }
}


.sub-panels {
  padding: 0 1.25rem 1.25rem;
}

.sub-panel-banner.accordion {
  .card {
    border: none;

    .accordion-collapse.collapsing {
      transition: height 0.3s ease-in-out;
      overflow: hidden;
    }

    .card-header {
      min-height: 2.1em;
      padding: .50rem 1.25rem;
      background: $white;

      .sub-panel-banner-header {
        min-height: 2.2em;
      }

      .sub-panel-header-toggle {
        border-radius: 50%;

        .hidden-subpanel-buttons-count {
          top: -7px;
          right: -10px;
          background: $sky-blue;
          color: $white;
          border-radius: 7px;
        }

        svg {
          font-size: 1.1em;
        }

        &:hover {
        }
      }

      a.clickable {
        color: $midnight-blue;
        font-weight: bold;

        svg {
          fill: $midnight-blue;
        }
      }
    }

    .card-body {
      padding: 0;
    }
  }

  a {
    &:hover {
      text-decoration: none;
    }
  }
}


.sub-panel {

  &:first-child {
    .card.panel-card {
      margin-top: 0.3em;
    }
  }
  table {
    tr {
      td:first-child,
      th:first-child {
        padding-left: 1.3em;
      }

      td:last-child,
      th:last-child {
        padding-right: 1.3em;
      }
    }
  }

  .table .show-more-column {
    float: none !important;
    width: 16px;

    scrm-record-details-popup-button {
      display: flex;
      width: 100%;

      scrm-popup-button {
        display: flex;
        width: 100%;

        scrm-button {
          display: flex;
          justify-content: center;
          width: 100%;
        }
      }
    }
  }
}
