/* ===== css/backend.css ===== */
/**
 * Shared CSS - loaded on both frontend and block editor.
 * Keep this file lean - only variables and styles needed in both places.
 */

/* Form */
.snb-form.snb-cookie-banner-form {
  .preferences {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    .snb-form-field {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;

      &.toggle {
        --toggle-padding: 4px;

        @media (max-width: 480px) {
          --toggle-padding: 3px;
          --toggle-font-size: 0.75rem;

          .toggle-label {
            width: 100%;
            padding: 0.5rem;

            .toggle-text {
              padding: 8px 10px;
            }
          }
        }
      }
    }
  }
  
  .button {
    position: relative;
    background-color: var(--wp--custom--color--action-primary);
    color: var(--wp--custom--color--text);
    padding: 14px 20px;
    border: none;
    border-radius: var(--snb-form-border-radius);
    cursor: pointer;
    font-weight: 700;
    transition: all var(--transition-duration) var(--transition-easing);

    &:hover {
      background-color: var(--wp--custom--color--action-primary-hover);
      color: var(--wp--custom--color--text);
    }

    &:active {
      background-color: var(--wp--custom--color--action-primary-active);
      color: var(--wp--custom--color--text);
    }

    &:disabled {
      background-color: var(--wp--custom--color--action-primary-disabled);
      color: var(--wp--custom--color--text-subtle);
      cursor: default;
    }

    &[data-busy="true"] {
      &::after {
        content: "";
        display: none !important;
      }
    }
  }
}



/* SNB Options pages */
.snb-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1rem 0 3.5rem;

  @media (max-width: 840px) {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat {
    padding: 1rem;
    border: 1px solid var(--wp--custom--color--line-subtle);
    border-radius: 0.5rem;
    display: flex;
    font-size: 1.5rem;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.5rem;
    background-color: var(--surface-brand-secondary-subtle);

    .value {
      place-self: end;
      font-family: var(--wp--custom--typography--primary);
      font-size: 3rem;
      font-weight: 700;
      line-height: 1;
      color: var(--text-heading-secondary);
      display: flex;
      align-items: center;
      gap: 0.5rem;

      &.number, .number {
        font-size: 4rem;
      }

      .opt-in {
        color: var(--wp--custom--color--text-success-default);
      }

      .opt-out {
        color: var(--wp--custom--color--text-danger-default);
      }
    }
  }
}

.snb-cookie-filters {
  margin-bottom: 0.75rem;
}



/* ===== css/components/index.css ===== */
.modal.cookie-banner {
  --modal-dialog-scrollable-content-max-height: 226px;

  .dialog {
    .container {
      display: grid;
      grid-template-columns: 50% 50%;
      width: 200%;
      transition: transform var(--transition-duration) var(--transition-easing);

      &.show-details {
        transform: translateX(-50%);
      }

      .inner {
        width: 100%;
      }

      &.show-details .scrollable-content {
        max-height: 50svh;
        
        @media (max-height: 680px) {
          max-height: 34svh;
        }
      }
    }
  
    .content {
      .information {
        button.content-nav {
          padding: 0.5rem 1rem;
          border-radius: var(--wp--custom--border-radius--button);
          border: 0;
          font-weight: var(--wp--custom--font-weight--button);
          color: var(--wp--custom--color--action-secondary-text);
          background-color: var(--wp--custom--color--action-secondary);
          cursor: pointer;
          display: flex;
          align-items: center;
          justify-content: space-between;

          svg {
            max-width: none;
            width: 24px;
            height: 24px;
          }

          &:hover {
            color: var(--wp--custom--color--action-secondary-text-hover);
            background-color: var(--wp--custom--color--action-secondary-hover);
          }
        }
      }

      .title {
        margin: 0;
        line-height: 1.25;
      }
      
      .description {
        margin: 0 0 0.5rem 0;
      }
    
      .preferences {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
        padding: 0;
        border: 0;

        @media (min-width: 768px) {
          grid-template-columns: repeat(4, 1fr);
        }
      
        .legend {
          margin-bottom: 0.75rem;
          font-weight: 700;
        }
      }
    }
    .actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 0.5rem;

      @media (min-width: 600px) {
        grid-template-columns: repeat(3, 1fr);
      }
    }
  }
}

.cookie-known-script-service {
  --cookie-known-script-service-count-size: 21px;
  --cookie-known-script-service-spacing-size: 1rem;
  
  display: flex;
  flex-direction: column;

  .category {
    margin-inline: calc(var(--modal-dialog-padding-inline) * -0.5);
    background-color: transparent;
    border-inline: 1px solid transparent;

    &:first-of-type {
      border-top: 1px solid transparent;
    }

    &[open] {
      border-inline: 1px solid var(--wp--custom--color--line-subtle);

      &:first-of-type {
        border-top: 1px solid var(--wp--custom--color--line-subtle);
      }
    }

    summary {
      position: relative;
      display: flex;
      align-items: flex-start;
      padding:
        var(--cookie-known-script-service-spacing-size)
        calc(var(--modal-dialog-padding-inline) * 0.5)
        var(--cookie-known-script-service-spacing-size)
        calc(var(--modal-dialog-padding-inline) * 0.5 + var(--cookie-known-script-service-count-size) + 0.5rem);
      
      .summary-text {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        line-height: 1;

        .description {
          font-family: var(--lora);
          font-size: var(--sm);
          font-weight: 400;
          color: var(--text-body-default);
          margin: 0;
          line-height: 1.5;
        }
      }
        
      .count {
        position: absolute;
        top: 1rem;
        left: calc(var(--modal-dialog-padding-inline) * 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--cookie-known-script-service-count-size);
        height: var(--cookie-known-script-service-count-size);
        font-size: 0.75rem;        
        background-color: #333;
        color: #fff;
        border-radius: 999px;

        &.zero {
          background-color: #bbb;
        }
      }
    }
    
    .details-content {
      padding: var(--cookie-known-script-service-spacing-size) calc(var(--modal-dialog-padding-inline) * 0.5);
    }

    .details-content {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      border-top: 1px solid #bbb;
    }

    summary:hover {
      background-color: #f8f8f8;
    }

    &:first-of-type, summary:first-child {
      border-top-left-radius: 0.5rem;
      border-top-right-radius: 0.5rem;
    }
  }

  .known-script-service {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border: 1px solid var(--wp--custom--color--line-subtle);
    background-color: var(--surface-brand-secondary-subtle);
    border-radius: 1rem;
    padding: 1rem;

    a {
      word-break: break-all;
    }

    .cookie {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      border: 1px solid var(--wp--custom--color--line-subtle);
      border-radius: 0.5rem;
      margin-top: 1rem;
      padding: 1rem 1rem;
      background-color: var(--color-neutral-white);

      .details {
        display: flex;
        gap: 0.5rem;
        border-top: 1px solid var(--wp--custom--color--line-subtle);
        padding-top: 1rem;
        margin-top: 1rem;

        hr {
          width: 1px;
          border: none;
          background-color: var(--wp--custom--color--line-subtle);
        }

        .detail {
          flex-basis: 50%;
          display: flex;
          flex-direction: column;
          font-size: var(--sm);

          strong {
            font-size: var(--md);
          }
        }
      }
    }
  }
}


.cookie-widget {
  --widgets-reveal-width: 192px;
  --widget-color: var(--wp--custom--color--text-success-default);

  order: 1;

  .button {
    font-family: var(--wp--custom--typography--primary);
    border: none;
    padding: 0;
    cursor: pointer;

    .content {
      flex-grow: 1;
      display: flex;
      align-items: center;
      background-color: var(--widget-color);
      color: var(--wp--custom--color--text-inverted);
      font-size: var(--sm);
      padding-inline: 1rem;
      height: 100%;
    }
  
    svg {
      width: 46px;
      height: 46px;
      color: var(--widget-color);
    }
  }

  &:has(button.hidden) {
    display: none;
  }
}

.widgets {
  --widgets-height: 60px;
  --widgets-width: 70px;
  --widgets-bottom-position: 12px;
  --widgets-color: #f9f9f9;
  --widgets-reveal-width: 186px;

  position: fixed;
  inset-inline: 0;
  bottom: var(--widgets-bottom-position);
  z-index: 1;
  isolation: isolate;
  pointer-events: none;
  display: flex;
  justify-content: space-between;

  .widgets-left, .widgets-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .widgets-left {
    align-items: flex-start;
  }
  .widgets-right {
    align-items: flex-end;
  }
  
  .grecaptcha-badge {
    pointer-events: auto;
    bottom: var(--widgets-bottom-position) !important;
  }
}
  


/* ===== css/form/shared.css ===== */
.snb-form.snb-cookie-banner-form {
  .preferences {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    .snb-form-field {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;

      &.toggle {
        --toggle-padding: 4px;

        @media (max-width: 480px) {
          --toggle-padding: 3px;
          --toggle-font-size: 0.75rem;

          .toggle-label {
            width: 100%;
            padding: 0.5rem;

            .toggle-text {
              padding: 8px 10px;
            }
          }
        }
      }
    }
  }
  
  .button {
    position: relative;
    background-color: var(--wp--custom--color--action-primary);
    color: var(--wp--custom--color--text);
    padding: 14px 20px;
    border: none;
    border-radius: var(--snb-form-border-radius);
    cursor: pointer;
    font-weight: 700;
    transition: all var(--transition-duration) var(--transition-easing);

    &:hover {
      background-color: var(--wp--custom--color--action-primary-hover);
      color: var(--wp--custom--color--text);
    }

    &:active {
      background-color: var(--wp--custom--color--action-primary-active);
      color: var(--wp--custom--color--text);
    }

    &:disabled {
      background-color: var(--wp--custom--color--action-primary-disabled);
      color: var(--wp--custom--color--text-subtle);
      cursor: default;
    }

    &[data-busy="true"] {
      &::after {
        content: "";
        display: none !important;
      }
    }
  }
}


