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

.main-container {
  @include settings.settings-page-container;
}

@include settings.settings-page-header;

.settings-title {
  @include settings.settings-page-title;
  margin-bottom: 0.75rem;
}

.settings-description {
  @include settings.settings-page-description;
}

.settings-card {
  @include settings.settings-card;
}

.section-header {
  @include settings.settings-section-header;
}

.section-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;

  @media (max-width: 767px) {
    flex-direction: column;
    align-items: stretch;

    p-button {
      align-self: flex-end;
    }
  }
}

.section-header-text {
  flex: 1;
}

.section-title {
  @include settings.settings-section-title;
}

.section-description {
  @include settings.settings-section-description;
}

.section-body {
  @include settings.settings-section-body;
}

// Toggle list (Server Settings)
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toggle-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
  border: 1px solid var(--p-content-border-color);
  border-left: 3px solid var(--p-content-border-color);
  border-radius: 6px;
  padding: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease;

  &:hover {
    background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
  }

  &.is-active {
    border-left-color: var(--p-green-500);
  }

  &.sub-item {
    margin-left: 1.5rem;
    border-left-color: var(--p-orange-500);

    &.is-active {
      border-left-color: var(--p-green-500);
    }

    @media (max-width: 600px) {
      margin-left: 0;
    }
  }

  @media (max-width: 600px) {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.toggle-content {
  flex: 1;
  min-width: 0;
}

.toggle-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
  color: var(--p-primary-color);
  border-radius: 8px;
  flex-shrink: 0;

  .pi {
    font-size: 1rem;
  }

  &.sub-icon {
    width: 28px;
    height: 28px;
    background: color-mix(in srgb, var(--p-orange-500) 15%, transparent);
    color: var(--p-orange-500);
    border-radius: 6px;

    .pi {
      font-size: 0.875rem;
    }
  }
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.toggle-label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--p-text-color);
}

.toggle-status {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--p-text-muted-color);

  &.active {
    color: var(--p-green-400);
  }
}

.toggle-description {
  font-size: settings.$settings-description-size;
  color: var(--p-text-muted-color);
  line-height: 1.5;
  margin: 0;
  padding-left: calc(36px + 0.75rem);

  @media (max-width: 600px) {
    padding-left: 0;
  }
}

// Endpoints list
.endpoints-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.endpoint-item {
  background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
  border: 1px solid var(--p-content-border-color);
  border-left: 3px solid var(--p-primary-color);
  border-radius: 6px;
  padding: 1rem;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.endpoint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
  color: var(--p-primary-color);
  border-radius: 6px;
  flex-shrink: 0;

  .pi {
    font-size: 0.875rem;
  }
}

.endpoint-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.endpoint-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--p-text-color);
}

.endpoint-hint {
  font-size: settings.$settings-description-size;
  color: var(--p-text-muted-color);
}

.endpoint-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;

  @media (max-width: 600px) {
    flex-direction: column;
    align-items: stretch;

    p-button {
      align-self: flex-end;
    }
  }
}

.endpoint-input {
  flex: 1;
  width: 100%;
  font-family: monospace;
  font-size: settings.$settings-description-size;
}

// Empty state
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--p-text-muted-color);
  background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
  border-radius: 6px;

  .pi {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
  }

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

  .empty-subtitle {
    font-size: settings.$settings-section-description-size;
    margin: 0;
  }
}

// Users list
.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
  border: 1px solid var(--p-content-border-color);
  border-left: 3px solid var(--p-primary-color);
  border-radius: 6px;
  padding: 0.875rem 1rem;
  transition: background 0.2s ease;

  &:hover {
    background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
  }

  @media (max-width: 600px) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--p-primary-color);
  color: var(--p-primary-contrast-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.username {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--p-text-color);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: settings.$settings-description-size;
  color: var(--p-text-muted-color);

  .pi {
    font-size: 0.875rem;
  }
}

.sort-order-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
  color: var(--p-primary-color);
  border-radius: 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.user-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;

  @media (max-width: 600px) {
    justify-content: flex-end;
  }
}

// Dialog styles
.user-dialog {
  .p-dialog-content {
    padding: 1.5rem;
  }

  .p-dialog-footer {
    padding: 1rem 1.5rem;
  }
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  label {
    font-weight: 600;
    color: var(--p-text-color);
    font-size: settings.$settings-section-description-size;
  }

  input {
    width: 100%;
    padding: 0.75rem;
    transition: border-color 0.2s;

    &:focus {
      outline: none;
      border-color: var(--p-primary-color);
      box-shadow: 0 0 0 2px color-mix(in srgb, var(--p-primary-color) 20%, transparent);
    }

    &::placeholder {
      color: var(--p-text-muted-color);
    }
  }

  .form-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    color: var(--p-text-muted-color);
    font-size: 0.875rem;
    line-height: 1.4;
    margin-top: 0.25rem;

    .pi {
      font-size: 0.625rem;
      margin-top: 0.125rem;
      flex-shrink: 0;
    }
  }
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

// Access denied card
.access-denied-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: settings.$settings-card-border-radius;
  background: color-mix(in srgb, var(--ground-background) 85%, var(--p-red-600) 15%);
  border: 1px solid var(--p-content-border-color);
  border-left: 3px solid var(--p-red-500);
  max-width: 500px;

  > .pi {
    font-size: 1.5rem;
    flex-shrink: 0;
    color: var(--p-red-400);
  }

  .access-denied-content {
    h3 {
      margin: 0 0 0.5rem 0;
      font-size: 1rem;
      font-weight: 600;
      color: var(--p-red-300);
    }

    p {
      margin: 0;
      font-size: settings.$settings-section-description-size;
      line-height: 1.5;
      color: var(--p-text-muted-color);
    }
  }
}
