.responsive-table {
  min-width: 50rem;

  @media (max-width: 768px) {
    min-width: 100% !important;
    width: 100% !important;
  }
}

.directory-picker {
  display: flex;
  flex-direction: column;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--p-content-background);
  border-radius: 12px;
  overflow: hidden;

  @media (max-width: 768px) {
    width: 95vw;
    height: 90vh;
  }
}

.picker-header {
  padding: 0 1.5rem 2rem 1.5rem;
  border-bottom: 1px solid var(--p-content-border-color);
  background: var(--card-background);

  .header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-color);

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

  .text-secondary {
    color: var(--text-secondary-color);
  }
}

.breadcrumb-container {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--p-content-border-color);

  ::ng-deep {
    .p-breadcrumb {
      background: transparent;
      border: none;
      padding: 0;

      .p-breadcrumb-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
      }

      .p-breadcrumb-home {
        .p-menuitem-link {
          color: var(--primary-color);
          transition: all 0.2s;

          &:hover {
            color: var(--primary-hover-color);
            background: var(--p-surface-800);
            border-radius: 6px;
          }
        }
      }

      .p-menuitem-link {
        color: var(--text-color);
        padding: 0.5rem 0.75rem;
        border-radius: 6px;
        transition: all 0.2s;

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

      .p-breadcrumb-chevron {
        color: var(--text-secondary-color);
        margin: 0 0.25rem;
      }
    }
  }
}

.search-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--card-background);
  border-bottom: 1px solid var(--p-content-border-color);

  .search-input-wrapper {
    position: relative;
    flex: 1;

    ::ng-deep {
      .p-inputicon {
        color: var(--text-secondary-color);
      }
    }

    .clear-icon {
      position: absolute;
      right: 1rem;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-secondary-color);
      cursor: pointer;
      transition: color 0.2s;
      z-index: 1;

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

  .up-button {
    padding: 0.75rem 1rem;
    border-radius: 8px;
  }
}

.current-path {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--overlay-background);
  border-bottom: 1px solid var(--p-content-border-color);
  font-size: 0.875rem;

  .path-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary-color);
    font-weight: 500;
    white-space: nowrap;

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

  .path-value {
    color: var(--text-color);
    font-family: monospace;
    background: var(--p-surface-900);
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
  }

  .selected-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: var(--p-sky-500);
    color: white;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;

    i {
      font-size: 0.875rem;
    }
  }
}

.directory-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  background: var(--ground-background);

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

  &::-webkit-scrollbar-track {
    background: var(--overlay-background);
  }

  &::-webkit-scrollbar-thumb {
    background: var(--p-surface-700);
    border-radius: 4px;

    &:hover {
      background: var(--p-surface-600);
    }
  }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary-color);

  ::ng-deep .custom-spinner {
    .p-progress-spinner-circle {
      stroke: var(--primary-color);
    }
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary-color);

  .empty-icon {
    font-size: 4rem;
    color: var(--p-surface-700);
    margin-bottom: 1rem;
  }

  .empty-text {
    font-size: 1rem;
    margin: 0;
  }
}

.folder-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
  background: var(--card-background);
  border: 1px solid var(--p-content-border-color);
  border-radius: 8px;
  transition: all 0.2s;

  &.checked {
    background: rgba(var(--primary-color-rgb), 0.05);
    border-color: var(--primary-color);
  }

  &:hover {
    background: var(--overlay-background);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    .folder-icon {
      color: var(--primary-color);
      transform: scale(1.1);
    }

    .navigate-icon {
      opacity: 1;
      transform: translateX(4px);
    }
  }

  &.selected {
    .folder-content {
      background: rgba(var(--primary-color-rgb), 0.1);
    }
  }

  .folder-checkbox {
    display: flex;
    align-items: center;
    padding: 0.25rem;
    cursor: pointer;

    ::ng-deep {
      .p-checkbox {
        .p-checkbox-box {
          width: 20px;
          height: 20px;
          border-radius: 4px;
        }
      }
    }
  }

  .folder-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 6px;
    transition: all 0.2s;

    &:hover {
      background: rgba(var(--primary-color-rgb), 0.05);
    }
  }

  .folder-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--overlay-background);
    border-radius: 8px;

    .folder-icon {
      font-size: 1.5rem;
      color: var(--text-secondary-color);
      transition: all 0.2s;
    }
  }

  .folder-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;

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

    .folder-path {
      color: var(--text-secondary-color);
      font-size: 0.8rem;
      font-family: monospace;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .navigate-icon {
    color: var(--text-secondary-color);
    opacity: 0;
    transition: all 0.2s;
  }
}

.picker-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--p-content-border-color);
  background: var(--card-background);
  margin-bottom: 2rem;

  .footer-info {
    flex: 1;

    .selection-info {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--text-secondary-color);
      font-size: 0.9rem;

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

  .footer-actions {
    display: flex;
    gap: 0.75rem;

    button {
      min-width: 120px;
    }
  }
}

@media (max-width: 768px) {
  .directory-picker {
    border-radius: 0;
  }

  .picker-header,
  .search-bar,
  .current-path,
  .directory-list,
  .picker-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .folder-item {
    .folder-info {
      .folder-path {
        display: none;
      }
    }
  }

  .current-path {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;

    .path-value {
      width: 100%;
    }

    .selected-count {
      align-self: flex-start;
    }
  }

  .picker-footer {
    flex-direction: column;
    align-items: stretch;

    .footer-info {
      text-align: center;
    }

    .footer-actions {
      width: 100%;

      button {
        flex: 1;
      }
    }
  }
}
