@import "colors.less";
@import "shared-components";
@import "font-sizes";
@import "unified-rows.less";
@import "modal";
@import "toast";

.update-nag {
  display: none;
}

.wrap {
  margin: 0 0 0 0;
}

@media screen and (max-width: 850px) {

  .tabs {
    .documentation, #wpsi-toggle-options, .header-upsell {
      display: none;
    }
  }

  #wpsi-dashboard {

    .wpsi-grid-controls {
      display: flex;
      justify-content: end;
    }

    #wpsi-recent-table_wrapper {
      overflow: hidden;
    }

    .inside > div:nth-child(1) {
      float: none;
    }

    #wpsi-dashboard .wpsi-dataTables_wrapper {
      max-width: 650px;
    }

    #wpsi-toggle-arrows {
      margin-top: 6px;
    }

    // Second grid item top to prevent overflowing table
    .wpsi-item {
      margin-top: 10px;
    }

    .item-container {
      width: 95vw;
    }

    .wpsi-sub-title {
      padding-top: 30px;
    }

    .wpsi-rsssl, .wpsi-cmplz {
      button {
        margin-top: 120px;
      }
    }

    #settings {
      margin-left: 0;

      .item-container {
        width: 85vw;
        clear: both;

        #wpsi_select_dashboard_capability, #wpsi_select_term_deletion_period, .wpsi_term_length {
          font-size: @font-size-large;
        }
      }
    }
  }
}

/**
widget
 */
#dashboard_widget_wpsi, #wpsi-dashboard {
  font-size: @font-size-dashboard-widget;

  .inside {
    padding: 0;

    #wpsi-dashboard-widget {

      h3 {
        font-size: @font-size-h3;
        font-weight: 600;
        padding: 10px;
      }

      .wpsi-widget-logo {
        margin-left: 20px;
        display: flex;

        span {
          padding: 10px;
        }
      }

      #wpsi-dashboard-widget-footer {
        margin-top: 0;
        margin-bottom: 0;
        padding: 12px;
        border-top: 1px solid #eee;
        color: @light-text-color;
      }
    }
  }
}

#wpsi-dashboard {

  // Base typography
  font-size: @font-size-base;
  line-height: 1.5;
  color: @text-color;

  // Headings hierarchy
  h1 {
    font-size: @font-size-h1;
    font-weight: 600;
  }

  h2 {
    font-size: @font-size-h2;
    font-weight: 600;
    margin-bottom: 15px;
  }

  h3 {
    font-size: @font-size-h3;
    font-weight: 600;
    color: @table-head-text-color;
    margin: 0.675rem;
  }

  h4 {
    font-size: @font-size-large;
    font-weight: 600;
    margin-bottom: 8px;
  }

  // Standard text elements
  p {
    font-size: @font-size-base;
    margin-bottom: 15px;
  }

  // Table typography
  table {
    font-size: @font-size-base;

    th {
      font-size: @font-size-large;
      font-weight: 600;
    }

    td {
      font-size: @font-size-small;
    }
  }

  // Form elements
  input, select, textarea, button {
    font-size: @font-size-base;
  }

  // Icons
  .dashicons {
    font-size: @font-size-xl;
  }

  .wpsi-large-icon,
  .hit-icon {
    font-size: @font-size-icon;
  }

  .tabs {
    background: @background-color;
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-content: center;
    align-items: center;

    .tabs-content {
      display: flex;
      width: 100%;
      margin-left: 40px;
      align-items: center;
      @media screen and (max-width: 480px) {
        margin-left: 0;
      }
    }

    .tab-links {
      color: @light-text-color;
      display: flex;
      flex-direction: row;
      margin-left: 0;
    }

    .documentation-pro {
      display: flex;
      align-items: center;
    }

    .header-links {
      width: 90%;
      display: flex;
      justify-content: space-between;
    }

    #wpsi-toggle-arrows {
      margin-top: 6px;
    }

    .documentation {
      margin-right: 15px;
    }
  }
}

#wpsi-dashboard {

  /*
  *
  *   Dashboard styling
  *
  */

  .tab-text {
    color: @light-text-color;
    font-size: @font-size-tab-text;
    outline: 0;
    box-shadow: 0 0 0 0;
    text-decoration: none;

    &:focus {
      box-shadow: initial;
    }
  }

  .wpsi-settings-logo {
    display: inline-block;
    vertical-align: middle;
    height: 50px;
    width: 50px;
  }

  @media screen and (max-width: 480px) {
    .wpsi-settings-logo {
      display: none;
    }
  }

  .wpsi-settings-intro {
    margin-left: 0 !important;
  }

  .wpsi-date-container {
    background: @background-color;
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    margin-right: 15px;
    white-space: nowrap;
    @media screen and (max-width: 480px) {
      width: 18px;
      overflow: hidden;
    }

    &.wpsi-export {
      float: left;
    }
  }

  // Search
  .dt-search {
    float: right;
    margin-bottom: 0;
    font-weight: 500;

    .dt-input {
      border: 1px solid @border-color;
      padding: 0 30px 0 8px; // Right padding for the icon
      line-height: 2;
      min-height: 30px;
      width: 250px;
    }
  }

  .wpsi-search-container {
    float: right;
    margin-bottom: 0;
    margin-top: -5px; // Vertical alignment with title
  }

  .wpsi-search-input-wrapper {
    position: relative;
    display: inline-block;
  }

  .wpsi-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #777;
    pointer-events: none; // Clicks pass through to input
  }

  // Mobile responsive styles
  @media screen and (max-width: 480px) {
    .wpsi-search-container {
      margin-top: 0; // Different alignment for mobile
    }

    .dt-search .dt-input {
      width: 150px; // Narrower search field on mobile
    }
  }
  // End search

  .search-insights-dashboard {
    display: flex;
    flex-flow: row wrap;
    word-break: break-all;
  }

  .wp-search-insights-main .unix-timestamp {
    display: none;
  }

  /*
      Navigation & tabs
   */

  ul.tabs {
    margin: 0px;
    padding: 0px;
    list-style: none;
    height: 66px;

    li {
      background: none;
      color: @text-color;
      display: inline-block;
      padding: 15px 15px 15px 15px;
      cursor: pointer;
      margin: 0;

      &.current {
        background: @background-color;
        color: @text-color;
      }
    }
  }

  .tab-content {
    display: none;
    background: #F0F0F1; // Default WP background
    padding: 15px;
  }

  #wpsi-delete-selected, #wpsi-ignore-selected {
    .wpsi-delete-icon {
      display: none;
    }

    @media screen and (max-width: 480px) {
      .wpsi-delete-icon {
        display: block;
      }

      .wpsi-delete-text {
        display: none;
      }
    }
    display: none;
    text-shadow: none !important;
    vertical-align: middle;
    margin-right: 39px;
    margin-bottom: 10px;
    padding: 10px 10px;
    line-height: 12px;
    min-height: 25px;
  }

  #wpsi-delete-selected {
    margin-right: 20px;
  }

  #wpsi-ignore-selected {
    //margin-right: 50px;
  }

  .tab-content.current {
    display: inherit;
  }

  .current .tab-text {
    padding-bottom: 23px;
    border-bottom: 2px solid @color-error;
  }


  /*
    General table styling
  */

  #dashboard {
    //.wpsi-dataTables_wrapper {
    //  //max-width: 800px;
    //  display: flex;
    //  justify-content: space-between;
    //  flex-direction: column;
    //}

    .item-content {
      padding: 15px 20px;
      flex: 1;
      margin: 0 auto;
      position: relative;

      input[type="search"] {
        width: 250px;
        margin-right: 20px;
        border: 1px solid @border-color;
        //some style to prevent override from wp on mobile
        padding: 0 8px;
        line-height: 2;
        min-height: 30px;
        @media screen and (max-width: 480px) {
          width: 150px;
        }
      }

      table {
        border-collapse: collapse;
        margin: 0;
        padding: 0;
        table-layout: fixed;
        justify-content: normal;

        &.wpsi-dataTable {
          tbody {
            tr.wpsi-selected {
              background-color: @wpsi-blue-light;

              // Ensure text is readable on the blue background
              td {
                background-color: @wpsi-blue-light;

                a {
                  color: white;
                  text-decoration: underline;
                }
              }

              &:hover {
                background-color: lighten(@wpsi-blue-light, 5%);
              }
            }
          }
        }

        caption {
          height: 50px;
          text-align: left;
          margin-top: -10px;
          padding-bottom: 10px;
        }

        tbody tr {
          border-bottom: .1em solid @border-color;
        }

        tr {
          height: 40px;
          padding: .35em;
        }

        th,
        td {
          padding: .625em;
          text-align: left;
          font-size: @font-size-small;
        }

        th {
          color: @table-head-text-color;
          font-size: @font-size-large;

          &:focus {
            outline: none;
          }

          cursor: pointer;
          background-repeat: no-repeat;
          background-position: right;
        }

        tbody {
          color: @light-text-color;
        }

        tr:first-child {
          border-top-left-radius: .55rem;
          border-top-right-radius: .55rem;
        }

        tr:last-child {
          margin-bottom: 0;
          border-bottom-left-radius: .55rem;
          border-bottom-right-radius: .55rem;
        }
      }
    }
  }

  //give textarea in filter grid a full width
  .full-width .item-content {
    th {
      display: none;
    }

    td {
      padding: 0;

      textarea {
        height: 100px;
      }
    }
  }

  .wpsi-term {
    max-width: 250px;

    span {
      display: inline-block;
    }

    a {
      text-decoration: none;
      color: @light-text-color;
      max-width: 200px;
      display: block;
    }
  }

  .wpsi-ellipsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all .2s linear;
    white-space: nowrap;
    cursor: pointer;
  }

  .wpsi-ellipsis:focus, .wpsi-ellipsis:hover {
    color: transparent;
  }

  .wpsi-ellipsis:focus:after, .wpsi-ellipsis:hover:after {
    content: attr(data-text);
    overflow: visible;
    text-overflow: inherit;
    background: @background-color;
    position: absolute;
    left: auto;
    top: auto;
    width: auto;
    max-width: 30rem;
    border: 1px solid @border-color;
    border-radius: 5px;
    padding: 0.5rem;
    box-shadow: 0px 0px 5px 5px rgba(222, 222, 222, 0.2);
    white-space: normal;
    word-wrap: break-word;
    display: block;
    color: black;
    margin-top: -1.25rem;
    z-index: 2;
  }

  .wpsi-grid-controls {
    float: right;

    .wpsi-date-filter {
      border: 1px solid @border-color;
    }
  }

  .hit-icon {
    font-size: @font-size-icon;
  }

  .icon-cancel {
    color: @color-error;
  }

  .icon-ok {
    color: @color-success;
  }

  #term-link {
    text-decoration: none;
  }

  /*
      Table footer
   */

  .wpsi-table-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 10px;
    position: absolute;
    bottom: 45px;
    width: 100%;

    button {
      float: right;
    }
  }

  .wpsi-dt-pagination {
      flex: 1;
      margin-bottom: 10px;
      cursor: pointer;
      .dt-paging {
          nav {
              display: flex;
              flex-direction: row;
          }

          // Rest of pagination styling
          .dt-paging-button {
              color: @text-color;
              padding: 0.5em 1em;
              box-sizing: border-box;
              border: 1px solid @border-color;
              box-shadow: 0px 1px 1px @border-color;
              margin: 0 2px;
              background-color: white;

              &.next,
              &.previous {
                  padding: 0.5em 1.8em;
                  color: @brand-primary;
              }

              &.disabled {
                  // disabled styling
                  color: #aaaaaa;
                  background-color: #f9f9f9;
                  border-color: #e8e8e8;
                  cursor: not-allowed;
                  opacity: 0.7;
                  box-shadow: none;
              }

              &:hover {
                  background-color: #f9f9f9;
                  cursor: pointer;
              }

              &.current {
                  color: white;
                  background-color: @brand-primary;
                  border: 0;
              }
          }
      }
  }

    .wpsi-pagination-compact {
        .paginate_button {
            // Make buttons more compact when there are many pages
            padding: 0.3em 0.5em !important;

            // Hide some page numbers when we have too many
            &:nth-child(n+7):nth-child(-n+100) {
                display: none;
            }

            // But always show the first few, last few, and current page area
            &.current,
            &.current + .paginate_button,
            &.current - .paginate_button,
            &:first-child,
            &:nth-child(2),
            &:nth-last-child(1),
            &:nth-last-child(2) {
                display: inline-block !important;
            }
        }

        // Add overflow handling just in case
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

  #wpsi-recent-table_previous {
    padding: 0.5em 1.8em;
    color: @color-error;
  }

  #wpsi-recent-table_next {

  }

  /*
      No Results grid item
   */

  .wpsi-nr-overview {
    margin: 0 auto;
    width: 95%;
  }

  .wpsi-nr-title {
    font-size: @font-size-h3;
    font-weight: 700;
  }

  .wpsi-nr-title-in-widget {
    font-weight: 600;
  }

  .wpsi-nr-header {
    display: flex;
    flex-direction: column;
    height: 50px;
  }

  .wpsi-nr-header-items {
    padding-top: 10px;
    font-weight: 500;
  }

  .nr-widget-results-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding-top: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid @border-color;
  }

  // Trend indicators in results cards
  .wpsi-trend {
    margin-left: 8px;
    font-weight: 500;
    white-space: nowrap;

    &.wpsi-trend-up {
      color: @color-success;
    }

    &.wpsi-trend-down {
      color: @color-error;
    }

    &.wpsi-trend-new {
      background-color: @wpsi-blue;
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: bold;
    }

  }

  .popular-terms-title {
    padding-top: 15px;
  }

  .dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
  }

  .dot-and-text {
    display: flex;
  }

  .result-title {
    font-weight: 600;
    padding-left: 10px;
  }

  .dot-success {
    background-color: @color-success;
  }

  .dot-error {
    background-color: @color-error;
  }

  .wpsi-result-count {
    color: @light-text-color;
    padding-top: 10px;
    padding-left: 20px;
  }

  .wpsi-no-results {
    margin-top: -17px;
  }

  .wpsi-total-searches {
    padding-top: 25px;
    padding-bottom: 10px
  }

  .wpsi-search-count {
    font-size: @font-size-h3;
    font-weight: 700;
    float: right;
  }

  .date-btn-all-searches {
    position: absolute;
    right: 180px;
    margin-top: 5px;
  }

  .wpsi-nr-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;

    .dt-buttons {
      margin: 0 auto;
    }
  }

  /*
    Other plugins
   */


  .wpsi-bullet {
    height: 15px;
    width: 15px;
    border-radius: 50%;
    margin-right: 10px;
  }

  #wpsi-start-export {
    float: right;
  }

  /*
      *
      *   Settings page styling
      *
   */

  .wpsi-settings {
    .item-content {
      max-height: 325px;
      overflow-y: scroll;
    }
  }

  .wpsi-settings-intro {
    display: inline-block;
    padding-top: 10px;
    margin-bottom: 25px;
    margin-left: -58px;
  }

  .wpsi-settings-intro-text {
    font-weight: 600;
    font-size: @font-size-settings-intro;
    margin-left: 10px;
    display: inline-block;
    vertical-align: middle;
  }

  .rsp-image {
    height: 35px;
    margin-left: 10px;
    margin-bottom: -12px;
  }

  .form-table {
    padding-left: 50px;
  }

  .settings-title {
    display: flex;
    flex-direction: column;
  }

  @media screen and (max-width: 950px) {
    // Prevent sideways scrolling on mobile
    .settings-block {
      width: 85vw !important;
    }
  }

  .settings-title {
    display: flex;
    flex-direction: column;
  }

  #settings {
    .form-table th {
      padding-top: 16px;
      width: initial;
      font-weight: 400;
    }

    .wpsi-download-link {
      padding-top: 6px;
      margin-right: 20px;
    }

    input[type=text], textarea, select {
      border: 1px solid @border-color;
    }

    textarea {
      width: 100%
    }

    .wpsi-export-grid td {
      display: flex;
    }
  }

  #wpsi_exclude_admin {
    display: none;
  }

  .wpsi_term_length {
    width: 60px;
    text-align: center;
  }

  #clear-searches-btn-border {
    border-bottom: 1px solid @border-color;
    margin-bottom: 20px;
    width: 95%;
  }

  /*
    Tips and Tricks
   */

  .wpsi-tips-tricks {
    .item-content > div {
      display: flex !important;
      flex-direction: column;
      flex-wrap: wrap;
      height: 100px;
      margin-bottom: 10px;
      border-bottom: 1px solid @border-color;

      @media screen and (max-width: 480px) {
        flex-direction: row;
        height: auto;
        overflow: hidden;
      }

      .wpsi-tips-tricks-element {
        width: 45%;
        margin-right: 5%;
        color: @light-text-color;

        @media screen and (max-width: 480px) {
          width: 100%;
        }

        a {
          display: flex;
          align-items: center;
          text-decoration: none;
          color: @light-text-color;
          padding: 5px 0;

          &:hover {
            color: @brand-primary;

            .wpsi-bullet {
              background-color: @brand-primary;
            }
          }
        }

        .wpsi-bullet {
          flex-shrink: 0;
          width: 8px;
          height: 8px;
          background-color: @grey-light;
          border-radius: 50%;
          margin-right: 12px;
          transition: background-color 0.2s ease;
        }

        .wpsi-tips-tricks-content {
          flex: 1;
          line-height: 1.4;
          font-size: 14px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: inline-block;
          vertical-align: middle;
        }
      }
    }

    .item-content a {
      text-decoration: none;
    }

    // Button styling
    .button-upsell {
      margin-top: 16px;
      margin-left: 15px;
      display: block;
      clear: both;
    }
  }

  .wpsi-tips-tricks-container-title {
    border-bottom: 1px solid @border-color;
  }

  /*
      Fancy checkboxes
   */

  .wpsi-switch {
    input {
      display: none;
    }

    position: relative;
    display: inline-block;
    width: 40px;
    height: 21px;
  }

  .wpsi-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;

    &:before {
      position: absolute;
      content: "";
      height: 15px;
      width: 15px;
      left: 4px;
      bottom: 3px;
      background-color: @background-color;
      -webkit-transition: .4s;
      transition: .4s;
    }

    &.wpsi-round {
      border-radius: 20px;
    }

    &.wpsi-round:before {

      border-radius: 50%;
    }
  }

  input:checked + .wpsi-slider {
    background-color: @wpsi-blue;

    &:before {
      -ms-transform: translateX(17px);
      transform: translateX(17px);
      transform: translateX(17px);
    }
  }

  input:checked:disabled + .wpsi-slider {
    background-color: lighten(@wpsi-blue, 40%);
  }


  input:focus + .wpsi-slider {
    box-shadow: 0 0 1px @wpsi-blue;
  }

  /* Base tooltip styles */
  /* Make sure the tooltip container is also set to overflow visible */

  .wpsi-item,
  .item-container,
  .item-content,
  .wpsi-table,
  .wpsi-grid,
  .wpsi-grid .wpsi-item .item-container {
    overflow: visible !important;
  }

  /* Base tooltip styling */

  [data-wpsi-tooltip],
  .wpsi-tooltip-right,
  .wpsi-tooltip-bottom,
  .wpsi-tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
    overflow: visible !important;
    z-index: 10000000;
  }

  /* Force tooltip content to appear above everything else */

  .wpsi-tooltip-right:after {
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  }

  /* Ensure tooltip root element is positioned properly */

  [data-wpsi-tooltip] {
    position: relative;
  }

  /* Tooltip container and arrow */

  [data-wpsi-tooltip]:before,
  [data-wpsi-tooltip]:after,
  .wpsi-tooltip:before,
  .wpsi-tooltip:after,
  .wpsi-tooltip-right:before,
  .wpsi-tooltip-right:after,
  .wpsi-tooltip-bottom:before,
  .wpsi-tooltip-bottom:after {
    position: absolute;
    z-index: 10000001;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-in-out,
    visibility 0.2s ease-in-out,
    transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
    border-radius: 5px;
  }

  /* Tooltip arrow styling */

  [data-wpsi-tooltip]:before,
  .wpsi-tooltip:before,
  .wpsi-tooltip-right:before,
  .wpsi-tooltip-bottom:before {
    content: "";
    border: 6px solid transparent;
    background: transparent;
  }

  /* Tooltip content styling */

  [data-wpsi-tooltip]:after,
  .wpsi-tooltip:after,
  .wpsi-tooltip-right:after,
  .wpsi-tooltip-bottom:after {
    content: attr(data-wpsi-tooltip);
    padding: 8px;
    background-color: @tooltip-background-color;
    color: @tooltip-text-color;
    font-size: @font-size-base;
    line-height: 1.2;
    white-space: normal;
    word-wrap: break-word;
    min-width: 175px;
    max-width: 500px;
    width: auto;
    font-weight: 400;
    opacity: 0;
  }

  /* Show tooltips on hover/focus */

  [data-wpsi-tooltip]:hover:before,
  [data-wpsi-tooltip]:hover:after,
  [data-wpsi-tooltip]:focus:before,
  [data-wpsi-tooltip]:focus:after,
  .wpsi-tooltip:hover:before,
  .wpsi-tooltip:hover:after,
  .wpsi-tooltip:focus:before,
  .wpsi-tooltip:focus:after,
  .wpsi-tooltip-right:hover:before,
  .wpsi-tooltip-right:hover:after,
  .wpsi-tooltip-right:focus:before,
  .wpsi-tooltip-right:focus:after,
  .wpsi-tooltip-bottom:hover:before,
  .wpsi-tooltip-bottom:hover:after,
  .wpsi-tooltip-bottom:focus:before,
  .wpsi-tooltip-bottom:focus:after {
    visibility: visible;
    opacity: 1;
  }

  /* Position: Top (default) */

  [data-wpsi-tooltip]:before,
  [data-wpsi-tooltip]:after,
  .wpsi-tooltip:before,
  .wpsi-tooltip:after {
    bottom: 100%;
    left: 50%;
  }

  [data-wpsi-tooltip]:before,
  .wpsi-tooltip:before {
    margin-left: -6px;
    margin-bottom: -12px;
  }

  [data-wpsi-tooltip]:after,
  .wpsi-tooltip:after {
    margin-left: -80px;
  }

  [data-wpsi-tooltip]:hover:before,
  [data-wpsi-tooltip]:hover:after,
  [data-wpsi-tooltip]:focus:before,
  [data-wpsi-tooltip]:focus:after,
  .wpsi-tooltip:hover:before,
  .wpsi-tooltip:hover:after,
  .wpsi-tooltip:focus:before,
  .wpsi-tooltip:focus:after {
    transform: translateY(-12px);
  }

  /* Position: Bottom */

  .wpsi-tooltip-bottom:before,
  .wpsi-tooltip-bottom:after {
    top: 100%;
    bottom: auto;
    left: 50%;
  }

  .wpsi-tooltip-bottom:before {
    margin-top: -12px;
    margin-bottom: 0;
  }

  .wpsi-tooltip-bottom:hover:before,
  .wpsi-tooltip-bottom:hover:after,
  .wpsi-tooltip-bottom:focus:before,
  .wpsi-tooltip-bottom:focus:after {
    transform: translateY(12px);
  }

  /* Position: Right */

  .wpsi-tooltip-right {
    float: right;
  }

  .wpsi-tooltip-right:before,
  .wpsi-tooltip-right:after {
    bottom: 50%;
    left: 100%;
  }

  .wpsi-tooltip-right:before {
    margin-bottom: 0;
    margin-left: -12px;
    top: 3px;
  }

  .wpsi-tooltip-right:after {
    margin-left: 0;
    margin-bottom: -16px;
  }

  .wpsi-tooltip-right:hover:before,
  .wpsi-tooltip-right:hover:after,
  .wpsi-tooltip-right:focus:before,
  .wpsi-tooltip-right:focus:after {
    transform: translateX(12px);
  }

  /* Special case positioning */

  #settings .wpsi-tooltip-right {
    margin-left: 8px;
    margin-top: 1px;
  }

  .dashboard-tooltip-hits > span:nth-child(1) > span:nth-child(1) {
    margin-left: -135px;
  }

  .dashboard-tooltip-from > span:nth-child(1) > span:nth-child(1) {
    margin-left: -65px;
  }

}

/*
    Toggle boxes styling
 */

#wpsi-toggle-dashboard {
  margin-bottom: 10px;
  height: 90px;
  display: none;
  position: relative;
  background-color: @background-color;
  border: 1px solid rgb(204, 208, 212);
  border-top: 0;
  box-shadow: 0 0 0 transparent;

  #wpsi-toggle-dashboard-text {
    padding-top: 25px;
    padding-left: 35px;
    font-weight: 600;
  }

  #wpsi-checkboxes {
    padding: 10px 0 0 20px;

    .wpsi-toggle-items {
      margin-left: 15px !important;
    }
  }
}


#wpsi-toggle-link-wrap {
  width: 150px;

  #wpsi-show-toggles {
    width: 135px;
    background-color: @background-color;
    color: black;
    border-color: #ccc;
  }
}

.wpsi-thickboxheader {
  margin-top: 15px;
  font-weight: 600;
}

/*
Animated skeleton screen using CSS.

Create shapes using gradients that simulate solids.

Use `:empty` pseduo-class to show skeleton screen background only while container has no content (ex: for the "loading" state). When content is added to the container element, the pseudo-class selector won't match anymore and the skeleton screen will be removed automatically; no need to toggle a separate class on the container.

See: https://developer.mozilla.org/en-US/docs/Web/CSS/:empty

Animating one layer of the background which is a tilted linear gradient with white in the middle to achieve shine effect.
*/
.wpsi-skeleton:empty {

  width: 350px;
  height: 400px; /* change height to see repeat-y behavior */

  background-image: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 80%),
  linear-gradient(#dadada 20px, transparent 0),
  linear-gradient(#dadada 20px, transparent 0),
  linear-gradient(#dadada 20px, transparent 0),
  linear-gradient(#dadada 20px, transparent 0);

  background-repeat: repeat-y;

  background-size: 50px 160px, /* highlight */ 150px 160px,
  350px 160px,
  300px 160px,
  250px 160px;

  background-position: 0 0, /* highlight */ 0px 0,
  0px 40px,
  0px 80px,
  0px 120px;

  animation: shine 1s infinite;
}

@keyframes shine {
  to {
    background-position: 100% 0, /* move highlight to right */ 0px 0,
    0px 40px,
    0px 80px,
    0px 120px;
  }
}

/*

Settings block height

 */
.wpsi-grid .wpsi-item.wpsi-settings {
  height: auto;
  max-height: 650px; /* Increase from default 500px */
}

/* Adjust the content container height accordingly */
.wpsi-grid .wpsi-item.wpsi-settings .item-container {
  height: 630px; /* Increase from default 480px */
}

/* Adjust the item-content height */
.wpsi-grid .wpsi-item.wpsi-settings .item-content {
  height: 568px; /* Adjust from default 438px */
  overflow-y: auto;
}

/* Hide scrollbar when content doesn't overflow */
.wpsi-grid .wpsi-item.wpsi-settings .item-content:not(:hover)::-webkit-scrollbar {
  width: 0;
  background: transparent;
}

/* Show scrollbar on hover only when needed */
.wpsi-grid .wpsi-item.wpsi-settings .item-content:hover::-webkit-scrollbar {
  width: 8px;
}

.wpsi-grid .wpsi-item.wpsi-settings .item-content:hover::-webkit-scrollbar-thumb {
  background-color: #cdcdcd;
  border-radius: 4px;
}

/* For Firefox */
.wpsi-grid .wpsi-item.wpsi-settings .item-content {
  scrollbar-width: none;
  overflow-y: auto !important;
  max-height: 550px !important;
}

.wpsi-grid .wpsi-item.wpsi-settings .item-content:hover {
  scrollbar-width: thin;
  scrollbar-color: #cdcdcd transparent;
}

/* Fix grid item stacking */
.wpsi-grid .wpsi-item.wpsi-analytics {
  z-index: 2; /* Higher than tips and tricks block */
}

.wpsi-drag-handle {
  color: @title-text-color;
}

// Unified card styling for consistent design
.wpsi-card-container {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.wpsi-card-title {
  color: @table-head-text-color;
  font-size: @font-size-large;
  margin-bottom: 10px;
  font-weight: 600;
}

// Ensure proper spacing in cards without internal headers
.wpsi-data-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 15px;
  height: 100%;

  .wpsi-card-number {
    margin-top: 0;
    font-size: @font-size-card-number;
    font-weight: bold;
    color: @text-color;
    padding: 5px;

    .wpsi-trend {
      margin-left: 5px;
      white-space: nowrap;
      font-size: @font-size-base;
      font-weight: normal;
      opacity: 0.85;
    }

    .wpsi-trend-context {
      color: @light-text-color;
      opacity: 0.7;
      font-size: @font-size-small;
      white-space: nowrap;
    }
  }

  .wpsi-card-footer {
    color: @light-text-color;
    font-size: @font-size-small;
    padding: 5px;
  }

  // Colors for trend indicators
  .wpsi-trend-up {
    color: @color-success;
  }

  .wpsi-trend-down {
    color: @color-error;
  }

  // Class to hide the now-redundant headers
  .wpsi-card-header {
    display: none;
    font-size: @font-size-card-header;
  }
}

// Success and warning card colors
.wpsi-data-card.success {
  border-left: 4px solid @color-success;
}

.wpsi-data-card.warning {
  border-left: 4px solid @brand-primary;
}

// Maintain consistent card layouts across plugin
.wpsi-data-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

// Dashicon help
.dashicons-editor-help {
  color: @tooltip-color;
}

// Fix for tooltips in results block being hidden behind popular searches block
#wpsi-dashboard {
  // Give the grid items proper stacking behavior
  .wpsi-grid {
    .wpsi-item {
      // When tooltips are active, increase z-index dramatically
      &[data-table_type="results"] {
        &:hover {
          z-index: 1000 !important; // Make sure results block goes above all others when being interacted with
        }

        // Target the specific tooltip elements
        .wpsi-tooltip-right,
        .wpsi-tooltip-bottom,
        [data-wpsi-tooltip] {
          &:hover, &:focus {
            z-index: 100001 !important; // Even higher z-index for the actual tooltip
          }
        }
      }

      // Prevent popular searches block from having higher stacking priority
      &[data-table_type="popular"] {
        // Ensure it doesn't override other elements' z-index when not interacted with
        z-index: 1;
      }
    }
  }

  // Make sure tooltips themselves can break out of any containers
  .wpsi-tooltip-right:after,
  .wpsi-tooltip-bottom:after,
  [data-wpsi-tooltip]:after {
    // Increase z-index for all tooltip content
    z-index: 100002 !important;
  }
}

// Full overlay loading indicator
.wpsi-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;

  .wpsi-loading-content {
    text-align: center;
    background-color: white;
    padding: 20px 30px;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

    .wpsi-loading-spinner {
      display: inline-block;
      width: 30px;
      height: 30px;
      border: 3px solid rgba(0, 0, 0, 0.1);
      border-radius: 50%;
      border-top-color: @brand-primary;
      animation: wpsi-spin 1s ease-in-out infinite;
      margin-bottom: 10px;
    }

    .wpsi-loading-text {
      font-size: 14px;
      color: @text-color;
      margin-top: 10px;
    }

    .wpsi-loading-percentage {
      font-weight: bold;
      margin-left: 5px;
    }

    .wpsi-loading-progress-container {
      margin-top: 15px;
      width: 200px;
      height: 8px;
      background-color: #e2e4e7;
      border-radius: 4px;
      overflow: hidden;

      .wpsi-loading-progress {
        height: 100%;
        background-color: @brand-primary;
        width: 0%;
        transition: width 0.3s ease;
      }
    }
  }
}

@keyframes wpsi-spin {
  to {
    transform: rotate(360deg);
  }
}

// Make sure the count shows properly in different contexts
#wpsi-total-count,
.wpsi-search-count {
  font-weight: 500;
  font-size: @font-size-base;
}

// Improve responsiveness
@media (max-width: 782px) {
  .wpsi-search-count {
    font-size: @font-size-base;
  }
}

// Enhanced sorting indicators for DataTables
.wpsi-table {
  // Target the header container
  .dt-column-header {
    display: flex;
    align-items: center;
    position: relative; // Ensure relative positioning for absolute children
  }

  // Title text
  .dt-column-title {
    display: inline-block;
    vertical-align: middle;
  }

  // Style the sort indicator element directly
  .dt-column-order {
    position: relative; // For absolute positioning of pseudo elements
    width: 20px;
    height: 20px;
    margin-left: 4px;

    // Default state (sortable but not sorted)
    &::before {
      content: "";
      position: absolute;
      top: 9px; // absolute value for dot, we cannot get it perfectly centered with %
      left: 5px;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background-color: @grey-light;
      opacity: 0.6;
    }
  }

  // For active ascending sort
  th.dt-ordering-asc .dt-column-order {
    &::before {
      content: none; // Remove dot
    }

    &::after {
      content: "\f142"; // Dashicons arrow up
      font-family: dashicons;
      position: absolute;
      top: 50%;
      left: 7px;
      transform: translate(-50%, -50%); // Perfect centering
      font-size: 18px;
      color: @brand-primary;
      opacity: 1;
      font-weight: bold;
    }
  }

  // For active descending sort
  th.dt-ordering-desc .dt-column-order {
    &::before {
      content: none; // Remove dot
    }

    &::after {
      content: "\f140"; // Dashicons arrow down
      font-family: dashicons;
      position: absolute;
      top: 50%;
      left: 7px;
      transform: translate(-50%, -50%); // Perfect centering
      font-size: 18px;
      color: @brand-primary;
      opacity: 1;
      font-weight: bold;
    }
  }

  // Hide dot for columns that aren't sortable
  th:not(.dt-orderable-asc):not(.dt-orderable-desc) .dt-column-order::before {
    display: none;
  }

  // Hover effect
  th:hover .dt-column-order::before,
  th:hover .dt-column-order::after {
    opacity: 1;
  }
}

.wpsi-stat-trend {
  margin-left: 10px;
  display: inline-block;

  // Inherit existing wpsi-trend styles
  .wpsi-trend {
    font-size: @font-size-base;
    margin-left: 0;
  }

  .wpsi-trend-context {
    color: @text-color;
    opacity: 0.7;
    font-size: @font-size-small;
    white-space: nowrap;
  }
}

// Popular searches filter dropdown
.wpsi-popular-filter {
  position: relative;
  display: inline-block;

  select {
    padding: 5px 28px 5px 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    border-radius: 3px;
    border: 1px solid @border-color;
    color: @light-text-color;
    background-color: #fff;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"><path fill="%23555" d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;

    &:hover {
      border-color: #999;
    }

    &:focus {
      border-color: #5b9dd9;
      box-shadow: 0 0 2px rgba(30, 140, 190, 0.8);
      outline: none;
    }
  }
}

// Pagination styles
.wpsi-popular-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  position: fixed;
  bottom: 20px;
  gap: 10px;
  border-color: @border-color;

  .wpsi-pagination-btn {
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    box-shadow: 0px 1px 1px #e0e0e0;
    margin: 0 2px;
    background-color: white;
    padding: 0.5em 1.8em;
    color: #d7263d;
    cursor: pointer;

    &:hover:not([disabled]) {
      background-color: @border-color;
      cursor: pointer;
    }

    &[disabled] {
      opacity: 0.5;
      cursor: not-allowed;
    }
  }

  .wpsi-pagination-info {
    color: @text-color;
    font-size: 12px;
    padding: 0 10px;
  }
}

// Pro upsell box
.wpsi-pro-upsell {
  margin-top: 15px;
  padding: 12px;
  background-color: #f9f9e8;
  border: 1px solid #e5e5b8;
  border-radius: 3px;

  p {
    color: #666;
    margin: 0 0 10px 0;
    font-size: 13px;
  }

  a.button-primary {
    background-color: #d7263d;
    border-color: #c52236;

    &:hover {
      background-color: #c52236;
      border-color: #b31e30;
    }
  }
}

.daterangepicker {
  z-index: 100000 !important; // Higher than modal backdrop, to prevent issues on export

  // Make sure dropdowns within datepicker also stay on top
  .ranges, .drp-calendar, .drp-buttons {
    z-index: 100001 !important;
  }

  // Ensure the calendar stays visible
  &.show-calendar {
    z-index: 100000 !important;
  }
}
