// Copyright (C) 2023 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@import "../theme";

.pf-form {
  display: flex;
  flex-direction: column;

  &__button-bar {
    display: flex;
    justify-content: right;
    flex-direction: row-reverse;
    align-items: baseline;
    gap: 4px;
  }

  &__label {
    margin-bottom: 6px;
    font-size: smaller;
    font-weight: 500;
  }

  &__section {
    border: 1px solid var(--pf-color-border);
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    padding: 8px;
    margin-block: 8px;

    &-label {
      font-weight: 500;
      text-transform: uppercase;
      font-size: 0.7em;
      color: var(--pf-color-text-muted);
      padding: 0 2px;
    }
  }

  // Styles for common input elements
  .pf-checkbox,
  .pf-switch {
    margin-bottom: 6px;
  }

  .pf-select,
  .pf-text-input {
    margin-bottom: 8px;
  }

  .pf-select:invalid {
    border-bottom-color: var(--pf-color-danger);
    &:active,
    &:focus {
      box-shadow: 0 1px 0 0 var(--pf-color-danger);
    }
  }

  .pf-text-input:has(input:invalid) {
    border-bottom-color: var(--pf-color-danger);
    &:has(input:focus) {
      box-shadow: 0 1px 0 0 var(--pf-color-danger);
    }
  }
}

// Add some spacing around forms when placed inside a menu
.pf-menu {
  .pf-form {
    // Compensate for the uneven |4px 0| padding in pf-menu, resulting in an
    // even 4px padding all around the form.
    margin: 0 4px;
  }
}
