.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-container {
  background: white;
  border-radius: 12px;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-shrink: 0;

  .header-left {
    flex: 1;
    min-width: 0;

    .modal-title {
      font-size: 24px;
      font-weight: 600;
      color: #1f2937;
      margin: 0 0 12px 0;
      display: flex;
      align-items: center;
      gap: 8px;

      .title-icon {
        width: 28px;
        height: 28px;
        color: #10b981;
      }
    }

    .member-stats {
      display: flex;
      gap: 16px;
      flex-wrap: wrap;

      .stat-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 50px;

        .stat-number {
          font-size: 18px;
          font-weight: 600;
          color: #1f2937;
          line-height: 1;
        }

        .stat-label {
          font-size: 12px;
          color: #6b7280;
          margin-top: 2px;
        }

        &.stat-pending {
          .stat-number {
            color: #d97706;
          }

          .stat-label {
            color: #92400e;
          }
        }
      }
    }
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;

    .environment-indicator {
      .env-badge {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 500;

        &.env-wxwork {
          background-color: #dcfce7;
          color: #166534;
        }

        &.env-default {
          background-color: #f3f4f6;
          color: #6b7280;
        }
      }
    }

    .search-box {
      position: relative;
      display: flex;
      align-items: center;

      .search-icon {
        position: absolute;
        left: 12px;
        width: 18px;
        height: 18px;
        color: #6b7280;
      }

      .search-input {
        padding: 8px 12px 8px 36px;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        font-size: 14px;
        width: 200px;
        outline: none;
        transition: border-color 0.2s ease;

        &:focus {
          border-color: #10b981;
          box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
        }
      }
    }

    .filter-select {
      padding: 8px 12px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      font-size: 14px;
      outline: none;
      cursor: pointer;
      transition: border-color 0.2s ease;

      &:focus {
        border-color: #10b981;
      }
    }

    .close-btn {
      background: none;
      border: none;
      padding: 8px;
      border-radius: 6px;
      cursor: pointer;
      color: #6b7280;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;

      svg {
        width: 20px;
        height: 20px;
      }

      &:hover {
        background-color: #f3f4f6;
        color: #374151;
      }
    }
  }
}

.modal-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-height: 0;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #6b7280;

  .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
  }

  p {
    margin: 0;
    font-size: 16px;
  }
}

.error-state {
  text-align: center;
  padding: 60px 20px;
  color: #ef4444;

  .error-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.5;
  }

  h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #dc2626;
  }

  p {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #7f1d1d;
  }

  .retry-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: #dc2626;
    }
  }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;

  .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.3;
  }

  h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #374151;
  }

  p {
    margin: 0;
    font-size: 14px;
  }
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.member-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;

  &:hover {
    border-color: #10b981;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }

  &.status-active {
    background-color: #f0fdf4;
    border-color: #86efac;
  }

  &.status-pending {
    background-color: #fffbeb;
    border-color: #fcd34d;
  }

  &.status-group-only {
    background-color: #f9fafb;
    border-color: #d1d5db;
  }

  .member-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;

    .avatar-image {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .avatar-placeholder {
      width: 100%;
      height: 100%;
      background-color: #10b981;
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      font-weight: 600;
      text-transform: uppercase;
    }
  }

  .member-info {
    flex: 1;
    min-width: 0;

    .member-name {
      font-size: 16px;
      font-weight: 600;
      color: #1f2937;
      margin: 0 0 8px 0;
    }

    .member-meta {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 8px;

      .role-badge {
        font-size: 12px;
        padding: 4px 8px;
        border-radius: 12px;
        font-weight: 500;
        white-space: nowrap;

        &.role-customer-service {
          background-color: #dbeafe;
          color: #1e40af;
        }

        &.role-designer {
          background-color: #ede9fe;
          color: #5b21b6;
        }

        &.role-team-leader {
          background-color: #fef3c7;
          color: #92400e;
        }

        &.role-admin {
          background-color: #fee2e2;
          color: #991b1b;
        }

        &.role-external {
          background-color: #f3f4f6;
          color: #6b7280;
        }

        &.role-default {
          background-color: #f3f4f6;
          color: #6b7280;
        }
      }

      .member-department {
        font-size: 12px;
        color: #6b7280;
        background-color: #f3f4f6;
        padding: 2px 6px;
        border-radius: 4px;
      }

      .member-status {
        font-size: 11px;
        padding: 2px 8px;
        border-radius: 12px;
        font-weight: 500;
        white-space: nowrap;

        &.status-active {
          background-color: #dcfce7;
          color: #166534;
        }

        &.status-pending {
          background-color: #fef3c7;
          color: #92400e;
        }

        &.status-group-only {
          background-color: #f3f4f6;
          color: #6b7280;
        }
      }
    }

    .add-to-group-hint {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: #d97706;
      margin-top: 4px;

      svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
      }
    }
  }

  .member-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;

    .action-btn {
      background: none;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      padding: 8px 12px;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      font-weight: 500;
      white-space: nowrap;

      svg {
        width: 16px;
        height: 16px;
      }

      &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
      }

      &.add-btn {
        background-color: #10b981;
        border-color: #10b981;
        color: white;

        &:hover {
          background-color: #059669;
        }
      }
    }

    .status-indicator {
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      font-size: 12px;

      &.status-active {
        background-color: #10b981;
        color: white;
      }

      &.status-pending {
        background-color: #f59e0b;
        color: white;
      }

      &.status-group-only {
        background-color: #6b7280;
        color: white;
      }
    }
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

// 响应式设计
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0;
  }

  .modal-container {
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header {
    padding: 16px;
    flex-direction: column;
    gap: 16px;

    .header-left {
      .modal-title {
        font-size: 20px;
      }

      .member-stats {
        justify-content: center;
        gap: 12px;
      }
    }

    .header-right {
      width: 100%;
      flex-direction: column;
      gap: 12px;

      .search-box .search-input {
        width: 100%;
      }

      .filter-select {
        width: 100%;
      }
    }
  }

  .modal-content {
    padding: 16px;
  }

  .member-card {
    padding: 12px;
    gap: 12px;

    .member-avatar {
      width: 40px;
      height: 40px;
    }

    .member-info {
      .member-name {
        font-size: 14px;
      }

      .member-meta {
        gap: 6px;
        flex-wrap: wrap;

        .role-badge {
          font-size: 11px;
          padding: 2px 6px;
        }

        .member-department {
          font-size: 11px;
        }

        .member-status {
          font-size: 10px;
          padding: 2px 6px;
        }
      }

      .add-to-group-hint {
        font-size: 11px;
        gap: 4px;
      }
    }

    .member-actions {
      flex-direction: row;
      gap: 8px;

      .action-btn {
        padding: 6px 10px;
        font-size: 11px;

        &.add-btn {
          span {
            display: none;
          }
        }
      }
    }
  }
}

@media (max-width: 480px) {
  .member-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;

    .member-info {
      text-align: center;

      .member-meta {
        justify-content: center;
      }
    }

    .member-actions {
      flex-direction: row;
      justify-content: center;
    }
  }
}