/* Dialog Animations and Styles */
.dialog {
  --_dialog-row-gap: 1rem;
  --_dialog-column-gap: 1rem;
  --_dialog-fieldset-gap: 1.5rem;

  border: none;
  padding: 0;
  background: var(--white-clr);

  transition-property: opacity, transform;
  transition-duration: 300ms;
  transition-behavior: allow-discrete;

  .close-btn {
    cursor: pointer;
    width: 1.5rem;
    height: 1.5rem;
    aspect-ratio: 1;
    display: block;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-clr);

    svg {
      margin: auto;
    }
  }
}

/* Sidebar Dialog */
.sidebar-dialog {
  &[data-position="left"] {
    margin-right: auto;
    box-shadow: 0 0 -20px hsla(0, 0%, 0%, 0.1);

    opacity: 0;
    transform: translateX(-100%);

    &[open] {
      opacity: 1;
      transform: translateX(0);

      @starting-style {
        opacity: 0;
        transform: translateX(100%);
      }
    }
  }

  &[data-position="right"] {
    margin-left: auto;
    box-shadow: 0 0 20px hsla(0, 0%, 0%, 0.1);

    opacity: 0;
    transform: translateX(100%);

    &[open] {
      opacity: 1;
      transform: translateX(0);

      @starting-style {
        opacity: 0;
        transform: translateX(100%);
      }
    }
  }
}

/* Central Dialog */
.central-dialog {
  margin: auto;
  width: min(90%, var(--_sidebar-width, 500px));
  max-height: 90vh;

  opacity: 0;
  transform: scaleY(0.95);

  &[open] {
    opacity: 1;
    transform: scaleY(1);

    @starting-style {
      opacity: 0;
      transform: scaleY(0.95);
    }
  }
}

/* Backdrop styles */
.dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);

  opacity: 0;
  transition-property: opacity overlay;
  transition-duration: 1000ms;
  transition-behavior: allow-discrete;
}

.dialog[open]::backdrop {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }
}

/* Delete Dialog */
.delete-dialog {
  padding: 1rem 1rem 2rem;
  border-radius: 0.5rem;
  width: min(100%, var(--_sidebar-width, 420px));

  &[open] {
    display: grid;
    column-gap: 0.75rem;
    justify-content: stretch;

    > *:not(.btn) {
      grid-column: span 2;
    }
  }

  .dialog-title {
    justify-self: center;
  }

  .close-btn {
    justify-self: end;
  }
}

.dialog-title {
  font-weight: var(--fw-700);
  line-height: 20px;
}

.delete-dialog-description {
  justify-self: center;

  font-size: var(--fs-300);
  line-height: 19.2px;
  margin-block: 0.5rem 2rem;
}

/* Sidebar Dialog */
.sidebar-dialog {
  margin: 0;
  height: 100svh;
  max-height: 100svh;
  width: min(100%, var(--_sidebar-width, 500px));
  max-width: 100%;

  .scrollable-tabs {
    position: sticky;
    top: 0;
    padding-inline: 1rem;
    padding-top: 1rem;

    .tab {
      font-weight: var(--fw-400);
    }
  }

  .scrollable-tabs-1 {
    grid-column: 1/-1;

    padding: 1rem;
    position: sticky;
    top: 3.5rem;
    background-color: #f8fafc;
    border-bottom: 0;
  }

  form {
    display: flex;
    flex-direction: column;
  }

  fieldset {
    margin-top: var(--_dialog-fieldset-gap);
    display: grid;
    gap: var(--_dialog-row-gap) var(--_dialog-column-gap);
    border: none;

    &:last-of-type {
      margin-bottom: var(--_dialog-fieldset-gap);
    }
  }

  fieldset,
  .btns {
    padding-inline: var(--_dialog-column-gap);
  }

  legend {
    width: 100%;
    font-weight: var(--fw-600);
    line-height: 19.2px;
    padding-bottom: var(--_dialog-row-gap);
    margin-bottom: var(--_dialog-row-gap);
    border-bottom: 1px solid #d5d5d5;
  }

  .checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    input {
      width: auto;
    }

    label {
      padding-bottom: 0;
    }
  }

  .input-wrapper {
    color: var(--tertiary-clr);
    padding-top: 0.5rem;
  }

  .btns {
    margin-top: auto;
    position: sticky;
    padding-block: 0.75rem;
    border-top: 1px solid #d5d5d5;
    background-color: var(--white-clr);
    box-shadow: 0 -6px 3px hsla(0, 0%, 0%, 0.05);
    display: flex;
    bottom: 0;
    column-gap: var(--_dialog-column-gap);
  }

  .btn {
    flex-grow: 1;
  }
}

.sidebar-dialog-content {
  min-height: 100%;
  display: grid;
  grid-template-rows: 3.5rem 1fr;
}

.sidebar-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: #e9e9e9;
}

/* Filter Sidebar */
.filter-sidebar {
  .filter-form {
    height: 100%;
    gap: 0;
  }

  .filter-body {
    margin-top: 0;
  }

  .btn-filter {
    --_btn-clr: var(--primary-clr);
    --_btn-txt-clr: var(--white-clr);
  }

  .filter-body {
    gap: 0;
  }
}

.filter-sidebar :where(.filter-header) {
  padding: 1rem 1rem 1rem 2.125rem;

  p {
    font-family: Lato;
    font-size: 1.5rem;
    font-weight: var(--fw-800);
    line-height: 18px;
    letter-spacing: 0.02em;
  }

  .close-btn {
    cursor: pointer;
    margin-bottom: 2.5rem;
    margin-left: auto;
    padding: 0.25rem;
    color: #545f71;

    &:hover {
      color: var(--secondary-clr);
    }
  }
}

.filter-accordion:not(:last-of-type) {
  border-bottom: 1px solid var(--border-clr);
}

.filter-accordion[open] {
  transition: all 180ms ease;
  border-bottom-color: var(--secondary-clr);

  .filter-accordion-title::after {
    rotate: 135deg;
    /* transform-origin: 0 0; */
  }
}

/* Chage the previous sibling border color
   if the next sibling is open */
.filter-accordion:has(+ .filter-accordion[open]) {
  border-bottom-color: var(--secondary-clr);
}

.filter-accordion:not([open]) .filter-accordion-title:hover {
  background-color: #fbf9f8;
}

.filter-accordion-title {
  padding: 1.125rem 1rem;
  position: relative;
  font-size: var(--fs-600);
  font-weight: var(--fw-500);
  line-height: 18px;

  &::marker {
    content: "";
  }

  &::after {
    content: "\ebc0";
    width: 1.5rem;
    height: 1.5rem;
    position: absolute;
    right: 0;
    inset-block: 0;
    margin-block: auto;
    font-family: boxicons;
    font-size: 1.5rem;
    line-height: 1;
    color: hsl(0, 0%, 45%);
    transition: rotate 0.3s ease;
  }
}

.filter-content {
  padding: 0.5rem 1rem 1rem;
}

.filter-search,
.filter-input {
  width: 100%;
  padding: 0.875rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #bec0c6;
  color: #898989;
}

.filter-sidebar :where(.filter-list) {
  margin-block: 1rem;
  display: grid;
  /* gap: 1rem; */
  max-height: 200px;
  overflow-y: auto;

  li {
    padding: 1.125rem 1rem;

    &:hover {
      background-color: var(--secondary-clr-10);
      color: var(--secondary-clr);
    }

    &.active {
      color: var(--white-clr);
      font-weight: var(--fw-600);
      background-color: var(--secondary-clr);
    }
  }
}

.filter-sidebar :where(.filter-footer) {
  margin-top: auto;
  padding: 1rem;
  position: sticky;
  bottom: 0;
  background-color: var(--white-clr);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.625rem;
  border-top: 1px solid hsla(225, 7%, 35%, 0.2);
}

/* Applied filters */
.applied-filters {
  margin-block: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.applied-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.875rem;
  background-color: #e9ecef;
  border-radius: 0.5rem;
  font-size: 14px;
  border: 1px solid #9ba5b7;

  &:hover {
    background-color: #f7f7f7;
  }

  .applied-filter-title {
    font-weight: var(--fw-700);
  }
}

.remove-applied-filter {
  cursor: pointer;
  color: var(--black-clr);
  border: none;
  background: none;
}

.clear-all-filters {
  cursor: pointer;
  padding: 4px 12px;
  padding: 0.4rem 0.875rem;
  color: var(--white-clr);
  background-color: var(--secondary-clr);
  border-radius: 0.5rem;
  border: none;
  border: 1px solid var(--secondary-clr);

  &:hover {
    color: var(--secondary-clr);
    background-color: var(--secondary-clr-15);
  }
}

.office-dialog {
  --_sucess-clr: hsl(160, 84%, 39%);

  @media (width <=480px) {
    inset-block: auto 0;
    /* top: auto; */
    /* bottom: 0; */
    min-width: 100%;
    max-height: none;
  }

  .office-dialog-body {
    padding: 1rem;
    display: grid;
    gap: 2.5rem;
  }

  .link-container {
    display: flex;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #9ba5b7;
    border-radius: 0.5rem;
    transition: border-color 0.3s ease;

    &:focus-within {
      border-color: var(--primary-clr);
    }

    &:focus-within:has(.copied) {
      border-color: var(--_sucess-clr);
    }
  }

  .link-input {
    flex: 1;
    font-size: var(--fs-300);
    color: var(--text-clr);
    border: none;

    &:focus-visible {
      outline: none;
    }
  }

  .copy-btn {
    cursor: pointer;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--fs-300);
    font-weight: var(--fw-500);
    color: var(--white-clr);
    background: var(--primary-clr);
    border-radius: 0 0.5rem 0.5rem 0;
    border: none;
    transition: all 0.3s ease;

    &:hover {
      background: var(--secondary-clr);
    }

    &.copied {
      background: var(--_sucess-clr);
    }
  }
}
