@use '../../../../shared/styles/panel-shared' as panel;

.shelf-assigner {
  width: 550px;
  max-width: 550px;
  display: flex;
  flex-direction: column;

  @media (max-width: 640px) {
    width: 100%;
    max-width: 100%;
  }
}

.panel-header {
  @include panel.panel-header;
  border-bottom: none;
}

.shelves-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 2rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  min-height: 350px;
  max-height: 450px;
  overflow: hidden;

  @media (max-width: 480px) {
    padding: 1rem;
    min-height: 300px;
    max-height: 400px;
  }
}

.shelves-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--overlay-background);
  border-radius: 6px;
  gap: 0.5rem;

  .shelf-count {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;

    i {
      color: var(--primary-color);
    }
  }

  .shelf-search {
    flex: 1;
    max-width: 200px;
    position: relative;

    input {
      width: 100%;
      font-size: 0.85rem;
      padding: 0.375rem 2rem 0.375rem 2rem;
    }

    .clear-icon {
      position: absolute;
      right: 0.5rem;
      top: 50%;
      transform: translateY(-50%);
      cursor: pointer;
      color: var(--text-secondary-color);
      font-size: 0.75rem;
      z-index: 1;

      &:hover {
        color: var(--text-color);
      }
    }
  }

  @media (max-width: 480px) {
    padding: 0.5rem 0.625rem;
    flex-wrap: wrap;

    .shelf-count {
      font-size: 0.85rem;
    }

    .shelf-search {
      max-width: 100%;
      order: 1;
    }
  }
}

.shelves-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.25rem;
  min-height: 0;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: var(--overlay-background);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s ease;

    &:hover {
      background: var(--primary-color);
    }
  }

  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--overlay-background);
}

.shelf-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;

  &:hover {
    border-color: var(--primary-color);
    transform: translateX(3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);

    .shelf-icon {
      color: var(--primary-color);
      transform: scale(1.08);
    }
  }

  &.selected {
    border-color: var(--primary-color);

    .shelf-icon-wrapper {
      background: var(--primary-color);

      .shelf-icon {
        color: var(--primary-contrast-color);
      }
    }
  }

  .shelf-checkbox {
    display: flex;
    align-items: center;
  }

  .shelf-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    min-width: 0;

    .shelf-icon-wrapper, .shelf-icon-wrapper-empty {
      width: 34px;
      height: 34px;
    }

    .shelf-icon-wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--overlay-background);
      border-radius: 8px;
      flex-shrink: 0;

      .shelf-icon {
        font-size: 1.125rem;
        color: var(--text-secondary-color);
        transition: all 0.3s ease;
      }
    }

    .shelf-name {
      font-size: 0.9375rem;
      color: var(--text-color);
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  @media (max-width: 480px) {
    padding: 0.625rem;
    gap: 0.5rem;

    .shelf-label {
      gap: 0.5rem;

      .shelf-icon-wrapper, .shelf-icon-wrapper-empty {
        width: 32px;
        height: 32px;

        .shelf-icon {
          font-size: 1rem;
        }
      }

      .shelf-name {
        font-size: 0.875rem;
      }
    }
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  flex: 1;

  .empty-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--overlay-background);
    border-radius: 50%;
    margin-bottom: 1rem;

    .empty-icon {
      font-size: 2.5rem;
      color: var(--text-secondary-color);
      opacity: 0.5;
    }
  }

  .empty-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
  }

  .empty-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary-color);
    max-width: 350px;
    line-height: 1.5;
  }

  @media (max-width: 480px) {
    padding: 1.5rem 0.75rem;

    .empty-icon-wrapper {
      width: 60px;
      height: 60px;

      .empty-icon {
        font-size: 2rem;
      }
    }

    .empty-title {
      font-size: 1rem;
    }

    .empty-description {
      font-size: 0.8rem;
      max-width: 100%;
    }
  }
}

.dialog-footer {
  @include panel.dialog-footer;
  border-top: none;
}
